我有一个带有自定义分类法的自定义帖子类型,多年来一直运行良好,但最近我看到custom taxonomy doesn\'t show up in the individual custom post type anymore. 然而,它确实显示在列表中,我可以很好地快速编辑它。
我禁用了我们所有的插件和相同的问题。你知道我遗漏了什么吗?
这是我必须构建自定义帖子类型和分类的代码。
// 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\');