I’m trying to create a dropdown list with the list of a certain post type.
I saw that I could use the wp_dropdown_pages function to do that.
I added this code inside my td but when the page displays the code is not interpreted. The are only few examples to look at.
<td><?php wp_dropdown_pages(array('id'=>'marque0','post_type' => 'Brands')); ?></td>
additionally I need to filter a second dropdown list which contains only child post of the parent selected in the first dropdown. To do that I need the id of the parent post. How can I get this from the element selected in the first dropdown list ?
Thanks a lot.
Update :
I found a way to go around the usage of PHP inside the wordpress page, I created shortcodes to call the wp_dropdown_pages, then I use the shortcodes inside my page.
Surprisingly enough (!), just specify in your custom post type’s settings
'hierarchical' => true
, not thehierarchical
argument in wp_dropdown_pages() function.Then it should work: