Saltar navegación

[Resuelto] Preselcting Categories based of Custom field selection

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 3 years, 9 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 -

Zona horaria del colaborador: Asia/Hong_Kong (GMT+08:00)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por fleurP 3 years, 9 months ago.

Asistido por: Luo Yang.

Autor
Mensajes
#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