Skip Navigation

[Resolved] Dynamically populate checkboxes field with taxonomy terms

This support ticket is created 5 years, 11 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by Ben 5 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1162143

Ben

I am looking to be able to dynamically populate checkboxes fields (both on Post Fields and Term Fields) with the terms of a custom taxonomy.

I've seen a few solutions on the forum, but these all appear to be written to populate a dropdown field. Is there a way I can adapt this to populate a checkboxes field?

#1162482

Hi, unfortunately there is not currently a built-in way to dynamically populate field options in wp-admin field editors using the terms of a taxonomy. There is no documented API that allows this functionality. The only workaround I'm aware of is on the front-end of the site, where you can use generic fields in Forms. You can create a generic checkboxes field that uses a View of taxonomy terms to set the field options dynamically. However, this approach only works on the front-end of the site, and does not automatically adjust the available checkboxes field options in the backend of the site. You must continue to manually adjust those as needed.

#1163071

Ben

Thank you for your reply Christian.

So the code used in the two below threads could not be adapted for use with a checkboxes field? They seem to be doing exactly what I wish to achieve but with a select field. Please correct me if I have read the threads wrong, you guys know a lot more than me!

https://toolset.com/forums/topic/dynamically-populate-select-field-with-custom-taxonomy/

https://toolset.com/forums/topic/filling-a-select-box-from-terms-in-a-taxonomy/

#1163159

While the code can theoretically be adapted for use with checkboxes, the code utilizes an undocumented filter "wpt_field_options" to modify the options in each custom field. Undocumented filters are not technically supported, so I can't recommend using them. We have found that the wpt_field_options filter can cause unexpected problems with custom searches, so we do not recommend it any longer.

#1163677

Ben

Thank you Christian!

That makes perfect sense. I think I will stick to inputting these options in the manual way to avoid the chance of any problems down the line.

Thank you for all your help.