Custom Taxonomy not showing as option on custom post page

set up a custom post type for service and a custom taxonomy for service type. The services post type is showing up but there is no option on the page to add the services-type taxonomy. Here is my code:

function create_posttypes() {
register_taxonomy(  
    'service-type',  //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces). 
    'services',        //post type name
    array(  
        'hierarchical' => true,  
        'label' => 'Service Types',  //Display name
        'query_var' => true,
        'rewrite' => array(
            'slug' => 'service', // This controls the base slug that will display before each term
            'with_front' => false // Don't display the category base before 
        )
    )  
); 
//Services Post Type and Categories
$labels = array(
            'name' => __( 'Services' ),
                    'singular_name' => __( 'Service' ),
            'all_items' => __( 'All Services' ),
            'view_item' => __( 'View Service' ),
            'add_new_item' => __( 'Add New Service' ),
            'edit_item' => __( 'Edit Service' ),
            'update_item' => __( 'Update Service' ),
            'search_items' => __( 'Search Services' ),
            'not_found' => __( 'Not Found' ),
            'not_found_in_trash' => __( 'Not Found in Trash' ),
        );
$args = array(
            'label' => 'Services',
            'description' => 'Directory of Services',
            'labels' => $labels,
            'public' => true,
            'query_var' => true,
            'has_archive' => true,
            'rewrite' => array('slug'=> 'services', 'with_front' => false),
            'hierarchical' => false,
            'show_ui' => true,
            'show_in_menu' => true,
            'show_in_rest' => true,
            'show_in_nav_menus' => true,
            'show_in_admin_bar' => true,
            'menu_position' => 5,
            'can_export' => true,
            'exclude_from_search' => false,
            'publicly_queryable' => true,
            'capability_type' => 'post',
            'taxonomies' => array( 'post_tag','service-type'),
            'supports' => array('title','thumbnail', 'revisions', 'excerpt', 'editor')
        );
register_post_type( 'services', $args );
}

add_action( 'init', 'create_posttypes', 0 );

1 Answer
1

With the new WordPress admin area “show_in_rest” must be set to true for custom taxonomies to show up in page editor.

Leave a Comment