Skip Navigation

[Resolved] Add post titles to custom field dropdown

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.

This topic contains 2 replies, has 2 voices.

Last updated by randallH-3 2 years, 10 months ago.

Author
Posts
#2273803

How can i add post titles to custom field dropdown?

Thanks!

#2274069

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You'd need to write a custom script for this in PHP.

You can use the wpv_field_options filter to modify the options that appear in a Types select custom field.

So you would make a select custom field.

You would hook into the generation of the select dropdown using the wpv_field_options filter, and then perform a query (e.g. use get_posts) to get the posts whose titles you want to offer, iterate over them to produce an array of options in the required format, and return the array.

See the example in the documentation for the filter: https://toolset.com/documentation/programmer-reference/types-api-filters/#wpt_field_options

https://developer.wordpress.org/reference/functions/get_posts/

#2277327

My issue is resolved now. Thank you!