I added a taxonomy and custom post type, but for some reason, my taxonomy isn’t showing up when I add a new marker. I half expected it to be there like when selecting a category for a post, but it isn’t. Any ideas what the issue might be?

function register_mm_post_types()
{
    register_taxonomy('marker_types', 
        array('markers'), 
        array(
        'labels'            => array(
            'name'              => __('Marker type', 'moxxie'),
            'singular_name'     => __('Marker type', 'moxxie'),
            'search_items'      => __('Search marker types', 'moxxie'),
            'all_items'         => __('All marker types', 'moxxie'),
            'parent_item'       => __('Parent marker type', 'moxxie'),
            'parent_item_colon' => __('Parent marker type:', 'moxxie'),
            'edit_item'         => __('Edit marker type', 'moxxie'), 
            'update_item'       => __('Update marker type', 'moxxie'),
            'add_new_item'      => __('Add new marker type', 'moxxie'),
            'new_item_name'     => __('New marker type name', 'moxxie'),
            'menu_name'         => __('Marker types', 'moxxie')
        ),

        'show_ui'           => true,
        'query_var'         => true,
        'hierarchical'      => true,
        'show_admin_column' => true,
        'rewrite'           => array('slug' => 'marker_types')
    ));

    register_post_type('markers', 
        array(  'taxonomies'            => array('marker_types'),
                'labels'                => array(
                    'name'                  => __('Map markers', 'moxxie'),
                    'singular_name'         => __('Marker', 'moxxie'),
                    'add_new'               => __('Add a new marker', 'moxxie'),
                    'edit_item'             => __('Edit marker', 'moxxie'),
                    'new_item'              => __('New marker', 'moxxie'),
                    'view_item'             => __('View marker', 'moxxie'),
                    'search_items'          => __('Search in maps', 'moxxie'),
                    'not_found'             => __('No markers found', 'moxxie'),
                    'not_found_in_trash'    => __('No markers found in trash', 'moxxie')
                ),

                'has_archive'           => true,
                'show_in_rest'          => true,
                'hierarchical'          => true,
                'public'                => true,
                'menu_icon'             => 'dashicons-location',
                'capability_type'       => 'post'
    ));
}
add_action('init', 'register_mm_post_types', 1); 

As you can see, no taxonomy is shown. It would have to appear in the right-hand column, just like categories do in posts.

As you can see, no taxonomy

2 Answers
2

The Gutenberg editor relies on the REST API, so both post types and taxonomies require the show_in_rest parameter be set to true when registering them. Your post type has this, but it’s missing from your taxonomy.

Leave a Reply

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