I have a WordPress site where I’m using the Post Type section for it’s purpose as a blog but also have a custom post type (Composers) that I want to create categories for. the code I have includes the following
'capability_type' => 'page',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'exclude_from_search' => false,
'show_in_rest' => true,
'taxonomies' => array( 'category' ),
);
register_post_type( $post_type, $args );
but what I wind up with is both this and the main Post Type using the same list of categories. To avoid confusion I need the custom post type to have a separate list. The code can create multiple post types that will be used in the future and the ability to have separate category types for all will be useful. What do I need to change or add to make this happen?
2
Answers
In the end I used this code
You have to create new taxonomy by using this function register_taxonomy()
Here is docs:
https://developer.wordpress.org/reference/functions/register_taxonomy/
Then you just replace that taxonomy slug to your current taxonomies array value here: