我是Wordpress的新手。我正在尝试制作我正在制作的菜单或插件。 并且子菜单没有显示在任何地方。有人可以帮忙吗?
add_action('admin_menu', 'peewaMenu');
function peewaMenu()
{
add_menu_page( 'Peewa Serials', 'Peewa Keys', 'manage_options', 'main-peewa', 'peewaMain' );
add_submenu_page('peewaAdd', 'Add new customer', 'Add new customer', 'manage_options', 'main-peewa');
}
function peewaMain(){
include_once('peewa-admin.php');
}
function peewaAdd(){
include_once('peewa-addnew.php');
}
答案 0 :(得分:1)
根据docs,它应该是:
add_menu_page ( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '', string $icon_url = '', int $position = null )
add_submenu_page ( string $parent_slug, string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '' )
您的参数不匹配,因此它们应该是:
add_menu_page( 'Peewa Serials', 'Peewa Keys', 'manage_options', 'main-peewa', 'peewaMain' );
add_submenu_page('main-peewa', 'Add new customer', 'Add new customer', 'manage_options', 'main-peewa/1', 'peewaAdd');