I need to create a dropdown menu with “posts from a custom post type” as option.
This dropdown will be placed as custom meta box.
For example, I want all posts with the custom type “Video” as option in the select.
<select>
<option>post title n°1<option>
<option>post title n°2<option>
....
</select>
Thanks
Here is the code I’m using in a project I’m working on.
$select_id
is used as the name and id of the select,$post_type
is the type you want to be made into the select and$selected
is the post id you want selected in the select box.See: http://codex.wordpress.org/Function_Reference/wp_dropdown_pages
If you already know how to make the custom meta box, you can use
maybe like so :
Since my last answer was considered more of a question. I’ll answer with more of an answer. You could use the Magic Fields plugin 2 (note the 2 because that is a different but improved plugin). You can choose a ‘related type’ field from the admin boxes they offer. Of course you still can excavate how it’s done in this plugin if you want to create this function yourself, but at least there is somebody who figured it out.