[Resolved] Populate select field with list of posts in a custom post type
This support ticket is created 7 years, 3 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I created a custom fields group, added a select field and added it to a new cpt.
I added the code you shared to my theme's functions.php and changed 'my-select-field' with the slug of my select field.
Unfortunately nothing happens: when I create a new custom post the select field still shows 'option 1' instead of a list of posts.
To Get this to work you will need to replace the Text “Team Leader” with the name of the select field you wish to populate. then within the foreach you can define the fields that you want to show in the select field.
Please let me know if this helps or if further assistance is needed to get it working fully.
Thanks for this solution.
Since I am not a programmer I don't completely understand it though.
In my case I need a list of standard WP posts, so I changed 'team leader' to 'post' but no success so far.
I would like to show the post title in the foreach loop.
It works fine now, thank you!
Two more questions:
1. Is it possible to add a line like "Select an option" above the options list?
2. is multiselect possible? Can a user CTRL-select multiple options?
And one more question: how can I display the selected option value on the site? At the moment it just shows the id, while I need the title with a link.
I tried this:
[wpv-post-title id='[types field='waar-ben-ik-mee-bezig'][/types]']
but it doesn't work: it doesn't return the option selected, but the title of the custom post.