Navigation überspringen

[Gelöst] Preselcting Categories based of Custom field selection

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

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 vor 3 Jahre, 5 Monaten. 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 -

Zeitzone des Unterstützers: Asia/Hong_Kong (GMT+08:00)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von fleurP vor 3 Jahre, 5 Monaten.

Assistiert von: Luo Yang.

Author
Artikel
#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