1

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 );
  • This works fine for me. You might have something else that's causing a conflict. – MikeNGarrett May 29 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 Jun 4 at 18:46
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.