2

I have a custom post type with a custom taxonomy that has been working fine for years, but recently I've seen that the custom taxonomy doesn't show up in the individual custom post type anymore. However, it does show up in the listing and I can quick edit it just fine.

enter image description here

I disabled all our plugins and the same issue. Any ideas on what I'm missing?

This is the code I have to build the custom post type and taxonomy.

// Register Profiles
function cpt_profiles() {
    $labels = array(
        'name' => __( 'Profile', 'profile' ),
        'singular_name' => __( 'Profile', 'profile' ),
        'add_new' => __( 'Add Profile', 'profile' ),
        'all_items' => __( 'All Profiles', 'profile' ),
        'add_new_item' => __( 'Add New Profile', 'profile' ),
        'edit_item' => __( 'Edit Profile', 'profile' ),
        'new_item' => __( 'New Profile', 'profile' ),
        'view_item' => __( 'View Profile', 'profile' ),
        'search_items' => __( 'Search Profiles', 'profile' ),
        'not_found' => __( 'No Profiles found', 'profile' ),
        'not_found_in_trash' => __( 'No Profiles found in Trash', 'profile' ),
        'parent_item_colon' => __( 'Parent Profile:', 'profile' ),
        'menu_name' => __( 'Profiles', 'profile' ),
    );
    $rewrite = array(
        'slug'                  => 'profile',
        'with_front'            => false,
        'pages'                 => true,
        'feeds'                 => true,
    );
    $args = array(
        'labels' => $labels,
        'hierarchical' => false,
        'supports' => array( 'title', 'editor', 'author', 'revisions', 'thumbnail'),
        'taxonomies' => array( 'profile_category'),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'show_in_rest' => true,
        'menu_position' => 10,
        'menu_icon' => 'dashicons-universal-access',
        'show_in_nav_menus' => false,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => $rewrite,
        'capability_type' => 'post'
    );

    register_post_type( 'profile', $args );
}
add_action( 'init', 'cpt_profiles' );

// Register Profile Areas
function tax_profile_topics() {

    $labels = array(
        'name'                       => _x( 'Areas', 'Taxonomy General Name', 'text_domain' ),
        'singular_name'              => _x( 'Area', 'Taxonomy Singular Name', 'text_domain' ),
        'menu_name'                  => __( 'Areas', 'text_domain' ),
        'all_items'                  => __( 'All Items', 'text_domain' ),
        'parent_item'                => __( 'Parent Item', 'text_domain' ),
        'parent_item_colon'          => __( 'Parent Item:', 'text_domain' ),
        'new_item_name'              => __( 'New Area', 'text_domain' ),
        'add_new_item'               => __( 'Add Area', 'text_domain' ),
        'edit_item'                  => __( 'Edit Area', 'text_domain' ),
        'update_item'                => __( 'Update Area', 'text_domain' ),
        'view_item'                  => __( 'View Area', 'text_domain' ),
        'separate_items_with_commas' => __( 'Separate items with commas', 'text_domain' ),
        'add_or_remove_items'        => __( 'Add or remove items', 'text_domain' ),
        'choose_from_most_used'      => __( 'Choose from the most used', 'text_domain' ),
        'popular_items'              => __( 'Popular Items', 'text_domain' ),
        'search_items'               => __( 'Search Items', 'text_domain' ),
        'not_found'                  => __( 'Not Found', 'text_domain' ),
        'no_terms'                   => __( 'No items', 'text_domain' ),
        'items_list'                 => __( 'Items list', 'text_domain' ),
        'items_list_navigation'      => __( 'Items list navigation', 'text_domain' ),
    );
    $args = array(
        'labels'                     => $labels,
        'hierarchical'               => true,
        'public'                     => true,
        'show_ui'                    => true,
        'show_admin_column'          => true,
        'show_in_nav_menus'          => false,
        'show_tagcloud'              => false,
    );
    register_taxonomy( 'profile_category', array( 'profile' ), $args );

}
add_action( 'init', 'tax_profile_topics');

2 Answers 2

2

You missed the 'show_in_rest' => true in register_taxonomy(). The default value is FALSE, so if you use Gutenberg editor, your custom taxonomy will not be visible.

2
  • This did it. Thanks so much.
    – rmlumley
    Commented Jul 22, 2019 at 20:09
  • @rmlumley didn't you already have that? I see it in the code you shared, unless you updated it after getting the answer?
    – th3coop
    Commented Feb 21, 2021 at 5:32
0

I think so that will help you.

setup at register_taxonomy $args:

$capabilities = array (
        'manage_terms' => 'publish_mysuffix', //by default only admin
        'edit_terms' => 'publish_mysuffix',
        'delete_terms' => 'publish_mysuffix',
        'assign_terms' => 'publish_mysuffix' 
      );

changes, capatability_type property at cpt 'post' to:

'capability_type' => 'mysuffix'

Then should be grant the role's:

$admin = get_role('my_role_name_may_admin');
$admin_caps = array(
    'read',
    'edit_pages',
    'edit_published_pages',
    'edit_others_pages',
    'publish_pages',
    'edit_mysuffix',
    'edit_others_mysuffix',
    'edit_private_mysuffix',
    'edit_published_mysuffix',
    'publish_mysuffix',
    'read_private_mysuffixs',
    'delete_mysuffix',
    'delete_others_mysuffix',
    'delete_private_mysuffix',
    'delete_published_mysuffix'
);
foreach ($admin_caps as $cap) {
    $admin->add_cap($cap);
}

hook add_action('after_setup_theme', 'add_custom_roles');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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