Add custom taxonomy to editor’s side menu

Picture of categories heading in WordPress editor

In my theme, I’ve registered a custom taxonomy and attached it to a custom post type:

// functions.php
function create_custom_post_type() {
    register_taxonomy(
            'tags',
            'projects',
            array(
                'label'                     => 'Tags',
                'rewrite'                   => array('slug' => 'tag'),
                'public'                    => true,
                'hierarchical'          => true,
                'show_ui'               => true,
                'show_admin_column'         => true,
                'show_in_menu'              => true,
                'show_in_rest'              => true,
                'query_var'                 => true,
                'update_count_callback' => '_update_post_term_count',
            )
        );

    register_post_type('pk_projects',
        array(
            'labels' => array(
                'name'              => __('Projects', 'peak'),
                'singular_name'     => __('Project', 'peak'),
                'add_new_item'      => __('Add new project', 'peak'),
                'edit_item'         => __('Edit project', 'peak'),
                'new_item'          => __('New project', 'peak'),
                'view_item'         => __('View project', 'peak')
            ),
            'description' => 'Custom post type for displaying work projects',
            'public' => true,
            'has_archive' => true,
            'hierarchical' => true,
            'menu_icon' => 'dashicons-art',
            'menu_position' => 20,
            'taxonomies' => array('tags'),
            'show_in_menu' => true,
            // 'exclude_from_search' => false,
            // 'publicly_queryable' => true, // set to default value of public
            'rewrite' => array(
                'slug' => __('projects', 'peak'),
                'with_front' => false
            ),
            'show_in_rest' => true,
            'supports' => array(
                'title',
                'editor',
                'author',
                'excerpt',
                'thumbnail',
                'trackbacks',
                'revisions',
                'custom-fields',
                'page-attributes',
                'post-formats'
            )
        )
    );
}
add_action('init', 'create_custom_post_type');

This successfully adds ‘Projects’ post types to my theme, and I can add tags from the Projects quick-edit menu but I would like to be able to add tags from the editor, much like adding categories to a post. Example:

When I access one of my custom post types, there is no drop-down menu for my custom taxonomy.

Anyone know how to do this? I’ve read over the docs for register_post_type and register_taxonomy but haven’t been able to solve this.

Thanks!

Read more here:: Add custom taxonomy to editor’s side menu

Leave a Reply

Your email address will not be published. Required fields are marked *