Custom Taxonomy Not Showing Up on Post Page

I have a custom post type with a custom taxonomy that has been working fine for years, but recently I've seen that

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.

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

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.

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');
Share Improve this question asked Jul 22, 2019 at 19:42 rmlumleyrmlumley 1859 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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.

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

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

相关推荐

  • Custom Taxonomy Not Showing Up on Post Page

    I have a custom post type with a custom taxonomy that has been working fine for years, but recently I've seen that

    7小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信