我真的不知道该如何正确地问这个问题。我创建了一个带有名称徽章的自定义帖子类型,并为其添加了自定义分类法(级别、技能)。现在,我想向该自定义帖子添加一个子菜单项。这是我的自定义帖子:
add_action(\'init\', \'bsp_badges_register\');
function bsp_badges_register() {
$labels = array(
\'name\' =>_x(\'Badges\', \'post type general name\'),
\'singular_name\' =>_x(\'Badge\', \'post type singular name\'),
\'add_new\' =>_x(\'Add New\', \'badge item\'),
\'add_new_item\' =>__(\'Add New Badge Item\'),
\'edit_item\' =>__(\'Edit Badge Item\'),
\'new_item\' =>__(\'New Badge Item\'),
\'view_item\' =>__(\'View Badge Item\'),
\'search_items\' =>__(\'Search Badge\'),
\'not_found\' =>__(\'Nothing found\'),
\'not_found_in_trash\' =>__(\'Nothing found in Trash\'),
\'parent_item_colon\' => \'\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'menu_icon\' => \'dashicons-welcome-learn-more\',
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'menu_position\' => 75,
\'supports\' => array(\'title\',\'editor\',\'thumbnail\'),
\'has_archive\'=>true,
\'show_in_menu\'=>\'badge-school\'
//\'taxonomies\' => array(\'post_tag\',\'category\')
);
register_post_type( \'badge\' , $args );
flush_rewrite_rules();
我的分类法之一:
register_taxonomy(
\'skills\',
array(\'badge\'),
array(
\'hierarchical\'=>true,
\'public\'=>true,
\'label\'=>\'Skills\',
\'labels\'=>array(
\'name\'=> _x( \'Skills\', \'taxonomy general name\' ),
\'singular_name\'=>\'Skill\',
\'menu_name\'=>__(\'Skills\')
),
\'show_ui\'=>true,
\'rewrite\'=>array(\'slug\'=>\'skill\'),
)
);
然后我尝试添加这样的子菜单:
add_action(\'admin_menu\',\'bsp_plugin_menu\');
function bsp_plugin_menu(){
add_menu_page(\'Badge school\', \'Badge School\', \'manage_options\',\'badge-school\',\'bsp_students_function\',\'dashicons-welcome-learn-more\');
//my taxonomy
add_submenu_page(\'edit.php?post_type=badge\', \'Skills\', \'Skills\', \'manage_options\', \'edit.php?taxonomy=skill&post_type=badge\');
但它并没有显示出来。我只看到菜单徽章,其他什么都没有。也应该有添加新的职位,它没有显示。我不知道我做错了什么,也不知道如何修复。我需要在一个菜单中获得所有内容,因为我需要添加更多没有分类的子菜单。
我希望你能理解我的问题,正如我提到的,我真的不知道该怎么问这个问题。