Skip Navigation

[Resolved] Preselcting Categories based of Custom field selection

This thread is resolved. Here is a description of the problem and solution.

Problem:

Is it possible to pre-select or hide certain category options upon selecting a value in a custom drop down field in a CPT.

Solution:

There isn't such kind of built-in feature within Toolset plugins, you might consider custom codes, for example

https://toolset.com/forums/topic/preselcting-categories-based-of-custom-field-selection/#post-2287341

Relevant Documentation:

https://developer.wordpress.org/reference/hooks/save_post/

This support ticket is created 2 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by fleurP 2 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#2286781

Is it possible to pre-select or hide certain category options upon selecting a value in a custom drop down field in a CPT.

#2287341

Hello,

There isn't such kind of built-in feature within Toolset plugins, you might consider custom codes, for example, after user choose an option in the custom select field, and save the post, you can use WordPress action hook "save_post" to trigger a PHP function:
https://developer.wordpress.org/reference/hooks/save_post/
In this PHP function, get the custom select field value:
https://developer.wordpress.org/reference/functions/get_post_meta/
And setup the term's value of your custom taxonomy:
https://developer.wordpress.org/reference/functions/wp_set_object_terms/

#2287431

Thanks Luo Yang