在自定义分类注册的函数里,添加show_in_rest 为 true就可以。 这个原因通常因为版本升级引起。
//add custom taxonomies
add_action( 'init', 'creat_weblinks_taxonomies',0 );
function creat_weblinks_taxonomies() {
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => _x( 'links category', 'taxonomy general name', 'textdomain' ),
'singular_name' => _x( 'link category', 'taxonomy singular name', 'textdomain' ),
'search_items' => __( 'Search links category', 'textdomain' ),
'all_items' => __( 'All links category', 'textdomain' ),
'parent_item' => __( 'Parent links category', 'textdomain' ),
'parent_item_colon' => __( 'Parent links category:', 'textdomain' ),
'edit_item' => __( 'Edit links category', 'textdomain' ),
'update_item' => __( 'Update links category', 'textdomain' ),
'add_new_item' => __( 'Add New links category', 'textdomain' ),
'new_item_name' => __( 'New links category Name', 'textdomain' ),
'menu_name' => __( 'links category', 'textdomain' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'show_in_rest' => true,
);
register_taxonomy('resources_links',array('resource_links'),$args );
}
$product_cats_args = array(
'labels' => $product_cats_labels,
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => false,
'show_in_rest' => true,
'show_tagcloud' => false,
);
register_taxonomy( 'product_cats', array( 'collection' ), $product_cats_args );