在我选择术语并保存我的自定义帖子类型后,将使用整数值生成新的分类术语,并且每次都会选择这些术语。我不知道问题是什么,也没有在互联网上发现任何类似的问题。下面是一张具体情况的图片:http://prntscr.com/fvfqvf
注册职位类型
function tbs_register_post_type() {
$singular = \'Stylist\';
$plural = \'Stylists\';
$labels = array(
\'name\' => $plural,
\'singular_name\' => $singular,
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New \' . $singular,
\'edit_item\' => \'Edit \' . $singular,
\'new_item\' => \'New \' . $singular,
\'view_item\' => \'View \' . $singular,
\'view_items\' => \'View \' . $plural,
\'search_items\' => \'Search \' . $plural,
\'not_found\' => \'No \' . strtolower($plural) . \' found\',
\'not_found_in_trash\' => \'No \' . strtolower($plural) . \' found in trash\',
\'all_items\' => \'All \' . $plural,
\'archives\' => $singular . \' Archives\',
\'attributes\' => $singular . \' Attributes\',
\'insert_into_item\' => \'Insert into \' . strtolower($singular),
\'uploaded_to_this_item\' => \'Uploaded to this \' . strtolower($singular),
\'featured_image\' => $singular . \' Picture\',
\'set_featured_image\' => \'Set \' . strtolower($singular) . \' picture\',
\'remove_featured_image\' => \'Remove \' . strtolower($singular) . \' picture\',
\'use_featured_image\' => \'Use as \' . strtolower($singular) . \' picture\',
\'filter_items_list\' => \'Filter \' . strtolower($plural) . \' list\',
\'items_list_navigation\' => $plural . \' list navigation\',
\'items_list\' => $plural . \' list\'
);
$args = array(
\'label\' => $plural,
\'labels\' => $labels,
\'description\' => \'A custom plugin to create, edit, and delete stylists made for -.\',
\'public\' => true,
\'menu_position\' => \'2\',
\'menu_icon\' => \'dashicons-groups\',
\'supports\' => array(\'title\', \'thumbnail\'),
\'taxonomies\' => array(\'tbs_skills\', \'tbs_fun_facts\'),
\'has_archive\' => false,
\'rewrite\' => array(\'slug\' => \'stylists\')
);
register_post_type(\'tbs_stylists\', $args);
}
add_action(\'init\', \'tbs_register_post_type\');
注册分类法
function tbs_register_skills_taxonomy() {
$singular = \'Skill\';
$plural = \'Skills\';
$labels = array(
\'name\' => $plural,
\'singular_name\' => $singular,
\'all_items\' => _(\'All \'. $plural),
\'edit_item\' => _(\'Edit \' . $singular),
\'view_item\' => _(\'View \' . $singular),
\'update_item\' => _(\'Update \' . $singular),
\'add_new_item\' => _(\'Add New \' . $singular),
\'new_item_name\' => _(\'New \' . $singular . \' Name\'),
\'search_items\' => _(\'Search \' . $plural),
\'popular_items\' => _(\'Popular \' . $plural),
\'separate_items_with_commas\' => _(\'Separate \' . strtolower($plural) . \' with commas\'),
\'add_or_remove_items\' => _(\'Add or remove \' . strtolower($plural)),
\'choose_from_most_used\' => _(\'Choose from the most common \' . strtolower($plural)),
\'not_found\' => _(\'No \' . strtolower($plural) . \' found.\')
);
$args = array(
\'label\' => $plural,
\'labels\' => $labels,
\'description\' => \'A custom taxonomy for the stylists custom post type made for -.\',
\'public\' => true
);
register_taxonomy(\'tbs_skills\', \'tbs_stylists\', $args);
}
add_action(\'init\', \'tbs_register_skills_taxonomy\');
function tbs_register_fun_facts_taxonomy() {
$singular = \'Fun Fact\';
$plural = \'Fun Facts\';
$labels = array(
\'name\' => $plural,
\'singular_name\' => $singular,
\'all_items\' => _(\'All \'. $plural),
\'edit_item\' => _(\'Edit \' . $singular),
\'view_item\' => _(\'View \' . $singular),
\'update_item\' => _(\'Update \' . $singular),
\'add_new_item\' => _(\'Add New \' . $singular),
\'new_item_name\' => _(\'New \' . $singular . \' Name\'),
\'search_items\' => _(\'Search \' . $plural),
\'popular_items\' => _(\'Popular \' . $plural),
\'separate_items_with_commas\' => _(\'Separate \' . strtolower($plural) . \' with commas\'),
\'add_or_remove_items\' => _(\'Add or remove \' . strtolower($plural)),
\'choose_from_most_used\' => _(\'Choose from the most common \' . strtolower($plural)),
\'not_found\' => _(\'No \' . strtolower($plural) . \' found.\')
);
$args = array(
\'label\' => $plural,
\'labels\' => $labels,
\'description\' => \'A custom taxonomy for the stylists custom post type made for -.\',
\'public\' => true
);
register_taxonomy(\'tbs_fun_facts\', \'tbs_stylists\', $args);
}
add_action(\'init\', \'tbs_register_fun_facts_taxonomy\');
编辑帖子页面功能
function tbs_change_title_text($title){
$screen = get_current_screen();
if (\'tbs_stylists\' == $screen->post_type) $title = \'Enter stylist name\';
return $title;
}
add_filter(\'enter_title_here\', \'tbs_change_title_text\');
function tbs_move_metas() {
remove_meta_box(\'tagsdiv-tbs_skills\', \'tbs_stylists\', \'side\');
add_meta_box(\'tagsdiv-tbs_skills\', \'Skills\', \'post_categories_meta_box\', \'tbs_stylists\', \'normal\', \'high\', array(\'taxonomy\' => \'tbs_skills\'));
remove_meta_box(\'tagsdiv-tbs_fun_facts\', \'tbs_stylists\', \'side\');
add_meta_box(\'tagsdiv-tbs_fun_facts\', \'Fun Facts\', \'post_categories_meta_box\', \'tbs_stylists\', \'normal\', \'high\', array(\'taxonomy\' => \'tbs_fun_facts\'));
}
add_action(\'admin_init\', \'tbs_move_metas\');
如果有人能提供一些见解,我将不胜感激。非常感谢。