我无法在“自定义管理”菜单下显示自定义分类法。自定义帖子类型正确显示,但分类法不显示。
我添加了自定义帖子类型:\'show_in_menu\' => \'my-menu\'
My Custom Menu
- Custom Post Type 1
- Custom Post Type 2
- Custom Post Type 3
- Custom Taxonomy that can be used by Post Type 1/2/3
显示自定义分类法需要做什么?
UPDATE
这是我的代码:
function create_custom_admin_menu() {
add_menu_page(
\'My Menu\',
\'My Menu\',
\'read\',
\'my-menu\',
\'\',
\'dashicons-admin-page\',
10
);
}
add_action( \'admin_menu\', \'create_custom_admin_menu\' );
function create_custom_post_type_1() {
$labels = array(
\'name\' => _x( \'Custom Post 1\' ),
\'singular_name\' => _x( \'Custom Post 1\' ),
\'menu_name\' => __( \'Custom Post 1\' ),
);
register_post_type( \'custom-post-type-1\', array(
\'labels\' => $labels,
\'has_archive\' => false,
\'public\' => true,
\'show_in_menu\' => \'my-menu\',
\'supports\' => array( \'title\', \'editor\', \'auther\', \'excerpt\', \'custom-fields\', \'thumbnail\',\'comments\' ),
\'taxonomies\' => array( \'custom-taxonomy\' ),
\'exclude_from_search\' => false,
\'capability_type\' => \'post\',
)
);
}
add_action( \'init\', \'create_custom_post_type_1\' );
function register_custom_taxonomy() {
$labels = array(
\'name\' => _x( \'Custom Taxonomy\'),
\'singular_name\' => _x( \'Custom Taxonomy\' ),
\'menu_name\' => __( \'Custom Taxonomy\' ),
);
register_taxonomy( \'custom-taxonomy\', \'my-menu\', array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'query_var\' => true,
\'show_admin_column\' => true
) );
}
add_action( \'init\', \'register_custom_taxonomy\' );
UPDATE 2
我尝试了所有的方法,但没有任何效果:
register_taxonomy( \'custom-taxonomy\', \'my-menu\', [...]
register_taxonomy( \'custom-taxonomy\', \'custom-post-type-1\', [...]
register_taxonomy( \'custom-taxonomy\', array(\'custom-post-type-1\', \'custom-post-type-2\', \'custom-post-type-3\' ), [...]