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

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 );

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 );
Share Improve this question asked May 29, 2019 at 12:37 jppower175jppower175 2832 silver badges13 bronze badges 2
  • This works fine for me. You might have something else that's causing a conflict. – MikeNGarrett Commented May 29, 2019 at 15:41
  • Forgive what might sound like a silly question, but did you try going up to "Screen Options" and ensuring that your new taxonomy module is checked? When you expand Screen Options you should see a checkbox for 'Service Types' that you should check if it isn't. – Trisha Commented Jun 4, 2019 at 18:46
Add a comment  | 

1 Answer 1

Reset to default 6

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745419154a4626888.html

相关推荐

  • 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

    6小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信