I am going to create multiple post types, each with its own form for site members to fill out. Several of the forms will have a long dropdown list to choose from. Because the same dropdown list will appear in multiple forms, is there a way to create this list somewhere where it can be dropped into multiple forms?
Hi,
Thank you for contacting us and I'd be happy to assist.
To dynamically populate a list of options for a "select" type custom field, you can use the "wpt_field_options" filter:
https://toolset.com/documentation/programmer-reference/types-api-filters/#wpt_field_options
For example, in this reply, I've shared an example code snippet to populate a list of options for the field with the title "Dogs Sire", from a custom post type "dogs":
https://toolset.com/forums/topic/custom-field/#post-1190447
In this case, all posts from this post type will be used as an individual option in the select field, with the post title as the option title and the post ID as that option's value.
To have a reusable dynamic list, you can also add a custom post type that holds all these options as posts and populated them in the required fields, using the "wpt_field_options" filter.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Waqar,
Thank you for responding to my question. I'm sorry to say that I have no programming experience, so I did not understand your response or how to incorporate it into my site design.
Is the only way to accomplish this using code? If so, I may just go through the trouble of inputting the list multiple times manually for now.
Thanks again, Sean
My issue is resolved now. Thank you!