Hide specific parent categories from post edit

I have many custom post types and they all take advantage of wordpress categories. I therefore have several parent categories for each custom post type. Is there a way to hide the other parent categories when editing a certain custom post type?

In this screenshot for example I’d only like “Download Categories” to show while I’m in my custom post type “downloads”.

Read More

enter image description here

Related posts

Leave a Reply

1 comment

  1. Probably you’re making a wrong use of taxonomies. Instead of using only the Categories taxonomy, you should create several Custom Taxonomies.

    I mean Blog Categories, Download Categories, Team Departments, etc… should be different taxonomies, and you should assing each of these taxonomies to the custom post type(s) they’re related to…

    Check the function register_taxonomy() for further information.

    This is a very simple example:

    function register_download_category() {
        register_taxonomy(
            'downloadcategory',
            'downloads',
            array(
                'label' => 'Download Categories',
                'rewrite' => array( 'slug' => 'downloadcategory' ),
            )
         );
    }
    add_action( 'init', 'register_download_category' );
    

    In order to make queries by custom taxonomies you have to use the WP_Query Taxonomy Parameters.