I'm trying to create a dropdown-list of all my custom post types.
It would look like this:
<select> <option value="post">Post</option> <option value="book">Book</option> <option value="some-other-post-type">Something</option> <option value="team">Team Members</option> </select>
I have come across the
get_post_types() function which is supposed to get a list of all registered post type objects. But it doesn't show my custom post types...
Is it possible to get an array with the slug and the title of all the post types registered in a theme? Considering the number of post types is unknown and dynamic. Every time a new custom post type is added or removed, it should reflect in the dropdown list.
$args = array( 'public' => true, '_builtin' => false // Use false to return only custom post types ); $post_types = get_post_types( $args ); print_r($post_types);
It returns an empty array... no custom post types that I registered.