我创建了一个自定义的非层次分类法,并将其更改为显示为复选框,而不是标记云。然而,当我在帖子编辑器中,选择一个可用的标签,然后更新帖子时,会发生一些奇怪的事情。标记现在保存为标记ID号,标记ID号在标记元框中显示为选中的复选框。
以下是我的分类代码:
add_action( \'init\', \'create_cuturalmaptags_taxonomy\', 0 );
function create_cuturalmaptags_taxonomy() {
$labels = array(
\'name\' => _x( \'Tags\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Tag\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Tags\' ),
\'all_items\' => __( \'All Tags\' ),
\'parent_item\' => __( \'Parent Tag\' ),
\'parent_item_colon\' => __( \'Parent Tag:\' ),
\'edit_item\' => __( \'Edit Tag\' ),
\'update_item\' => __( \'Update Tag\' ),
\'add_new_item\' => __( \'Add New Tag\' ),
\'new_item_name\' => __( \'New Tag Name\' ),
\'menu_name\' => __( \'Tags\' ),
);
register_taxonomy(\'cuturalmap-tags\', array(\'post\'), array(
\'hierarchical\' => false,
\'meta_box_cb\' => \'post_categories_meta_box\',
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'cuturalmap-tags\' ),
));
}
下面是正在发生的事情的示例。当我去编辑帖子并选择我想要的标签时,它看起来很正常。
但一旦我更新了帖子,标签如下所示:
我在标签管理器中确认,该编号是我创建的标签的ID。发生这种情况的原因以及我如何解决?
这是我的CPT代码,其中调用了“culturalmap标记”。
// Cultural Mapping Custom Post Type
function culturalmap_post_type() {
$labels = array(
\'name\' => _x( \'Cultural Map\', \'Post Type General Name\', \'text_domain\' ),
\'singular_name\' => _x( \'Cultural Map\', \'Post Type Singular Name\', \'text_domain\' ),
\'menu_name\' => __( \'Cultural Mapping\', \'text_domain\' ),
\'parent_item_colon\' => __( \'Parent Cultural Map:\', \'text_domain\' ),
\'all_items\' => __( \'All Cultural Maps\', \'text_domain\' ),
\'view_item\' => __( \'View Post\', \'text_domain\' ),
\'add_new_item\' => __( \'Add New Cultural Map\', \'text_domain\' ),
\'add_new\' => __( \'Add New\', \'text_domain\' ),
\'edit_item\' => __( \'Edit Post\', \'text_domain\' ),
\'update_item\' => __( \'Update Cultural Map\', \'text_domain\' ),
\'search_items\' => __( \'Search Cultural Maps\', \'text_domain\' ),
\'not_found\' => __( \'Not found\', \'text_domain\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\', \'text_domain\' ),
);
$args = array(
\'label\' => __( \'Cultural Map\', \'text_domain\' ),
\'description\' => __( \'Post Type Description\', \'text_domain\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'excerpt\', \'author\', \'thumbnail\', \'custom-fields\' ),
\'taxonomies\' => array( \'cultural-mapping\', \'cuturalmap-tags\' ),
\'hierarchical\' => true,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'menu_icon\' => \'dashicons-admin-site\',
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
\'rewrite\' => array(\'slug\' => \'cultural-map\'),
);
register_post_type( \'culturalmap\', $args );
}
// Hook into the \'init\' action
add_action( \'init\', \'culturalmap_post_type\', 0 );