我添加了分类法和自定义帖子类型,但由于某种原因,在添加新标记时,我的分类法没有显示出来。我有点期待它会出现,就像在为一篇文章选择一个类别时一样,但事实并非如此。有什么想法吗?
function register_mm_post_types()
{
register_taxonomy(\'marker_types\',
array(\'markers\'),
array(
\'labels\' => array(
\'name\' => __(\'Marker type\', \'moxxie\'),
\'singular_name\' => __(\'Marker type\', \'moxxie\'),
\'search_items\' => __(\'Search marker types\', \'moxxie\'),
\'all_items\' => __(\'All marker types\', \'moxxie\'),
\'parent_item\' => __(\'Parent marker type\', \'moxxie\'),
\'parent_item_colon\' => __(\'Parent marker type:\', \'moxxie\'),
\'edit_item\' => __(\'Edit marker type\', \'moxxie\'),
\'update_item\' => __(\'Update marker type\', \'moxxie\'),
\'add_new_item\' => __(\'Add new marker type\', \'moxxie\'),
\'new_item_name\' => __(\'New marker type name\', \'moxxie\'),
\'menu_name\' => __(\'Marker types\', \'moxxie\')
),
\'show_ui\' => true,
\'query_var\' => true,
\'hierarchical\' => true,
\'show_admin_column\' => true,
\'rewrite\' => array(\'slug\' => \'marker_types\')
));
register_post_type(\'markers\',
array( \'taxonomies\' => array(\'marker_types\'),
\'labels\' => array(
\'name\' => __(\'Map markers\', \'moxxie\'),
\'singular_name\' => __(\'Marker\', \'moxxie\'),
\'add_new\' => __(\'Add a new marker\', \'moxxie\'),
\'edit_item\' => __(\'Edit marker\', \'moxxie\'),
\'new_item\' => __(\'New marker\', \'moxxie\'),
\'view_item\' => __(\'View marker\', \'moxxie\'),
\'search_items\' => __(\'Search in maps\', \'moxxie\'),
\'not_found\' => __(\'No markers found\', \'moxxie\'),
\'not_found_in_trash\' => __(\'No markers found in trash\', \'moxxie\')
),
\'has_archive\' => true,
\'show_in_rest\' => true,
\'hierarchical\' => true,
\'public\' => true,
\'menu_icon\' => \'dashicons-location\',
\'capability_type\' => \'post\'
));
}
add_action(\'init\', \'register_mm_post_types\', 1);
如您所见,没有显示分类法。它必须出现在右侧栏中,就像帖子中的类别一样。