According to the WordPress Codex, the get_post_types()
function has a 'taxonomies' parameter, but there is no explanation of exactly how it works.
$post_args = array(
'public' => true,
'taxonomies' => 'genre',
'show_ui' => true
);
$post_types = get_post_types($post_args);
This above code doesn't return anything even though genre is a taxonomy that is registered to the 'book' post type.
If i have a custom post type of 'books' with some custom taxonomies of say, 'author' and 'genre'... I'd like to use get_post_type()
to return the post type associated with 'genre'... obviously 'books'. I'm trying to make something that will help set the post_type
parameter in get_posts()
.. since that only searches posts by default and not custom post types. Obviously I could just set the post_type
parameter, but I want to make it forward compatible with any future post types I might use in my different themes.