How to add a custom taxonomy to a custom post type’s document tab

I created a custom taxonomy and wanted to add it to the side-menu of my portfolio custom post type (in the admin area). My custom taxonomy is not loading, but the default one (‘category’) does. What did I miss?

add_action( 'init', 'add_taxonomies' );    
function add_taxonomies() {
    register_taxonomy(
      'related_service',
      'portfolio',
      array(
        'label' => 'Related Services',
        'public' => true
      )
    );
  }

add_action( 'init', 'register' );
    function register() {
      register_post_type( 'portfolio', array(
        'label' => 'Portfolio',
        'public' => true,
        'show_in_rest' => true,
        'taxonomies'  => array( 'category', 'related_service' )
      ) );
    }

1 Answer
1

If you’re using the Block Editor you also need to add 'show_in_rest' => true for the taxonomy. You only have it for the CPT currently.

Leave a Comment