这里有一个片段,它似乎没有在CPT编辑屏幕中显示分类法。不确定出了什么问题,分类法和CPT都是相互注册的。
<?php
add_action(\'init\', \'create_taxonomy\');
function create_taxonomy() {
register_taxonomy( \'farm\', array(\'farmer\', \'food\', \'recipe\'), array(
\'label\' => \'farms\',
\'public\' => true,
\'show_ui\' => true,
\'show_in_nav_menus\' => true,
\'show_tagcloud\' => true,
\'hierarchical\' => true,
\'show_admin_column\' => true,
\'query_var\' => \'farm\',
\'update_count_callback\' => \'\',
\'sort\' => true,
\'labels\' => array(
\'name\' => __(\'Farms\'),
\'singular_name\' => __(\'Farm\'),
\'menu_name\' => __(\'Farm\'),
\'all_items\' => __(\'All Farms\'),
\'edit_item\' => __(\'Edit Farm\'),
\'view_item\' => __(\'View Farm\'),
\'update_item\' => __(\'Update Farm\'),
\'add_new_item\' => __(\'Add New Farm\'),
\'new_item_name\' => __(\'New Farm\'),
\'search_items\' => __(\'Search Farms\'),
\'popular_items\' => __(\'Popular Farms\'),
\'separate_items_with_commas\' => __(\'Separate farms by commas\'),
\'add_or_remove_items\' => __(\'Add or remove farms\'),
\'choose_from_most_used\' => __(\'Choose from the most popular farms\'),
\'not_found\' => __(\'No farms found\')
),
\'rewrite\' => array(
\'slug\' => \'farm\',
\'with_front\' => false,
\'hierarchical\' => false,
)
) );
register_post_type( \'farmer\', array(
\'public\' => true,
\'taxonomies\' => array( \'farm\' ),
\'menu_position\' => 6,
\'capability_type\' => \'page\',
\'rewrite\' => array( \'slug\' => \'farmer\' ),
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'custom-fields\' ),
\'labels\' => array(
\'name\' => __(\'Farmers\'),
\'menu_name\' => __(\'Farmers\'),
\'singular_name\' => __(\'Farmer\'),
\'add_new\' => __(\'Add New\'),
\'add_new_item\' => __(\'Add New Farmer\'),
\'edit_item\' => __(\'Edit Farmer\'),
\'new_item\' => __(\'New Farmer\'),
\'all_items\' => __(\'All Farmers\'),
\'view_item\' => __(\'View Farmer\'),
\'search_items\' => __(\'Search Farmers\'),
\'not_found\' => __(\'No farmers found\'),
\'not_found_in_trash\' => __(\'No farmers found in Trash\')
)
) );}
?>