Php 无法在wordpress的插件菜单下添加子菜单
我正在添加一个插件菜单(该菜单被正确添加)及其下的一个子菜单(该菜单从未显示),如下所示:Php 无法在wordpress的插件菜单下添加子菜单,php,wordpress,Php,Wordpress,我正在添加一个插件菜单(该菜单被正确添加)及其下的一个子菜单(该菜单从未显示),如下所示: //We'll call the action to add the menu when the plugin is loaded add_action( "plugins_loaded", "load" ); function load() { //Add us to the menu add_action( "admin_menu", "addToMenu" ); } functi
//We'll call the action to add the menu when the plugin is loaded
add_action( "plugins_loaded", "load" );
function load()
{
//Add us to the menu
add_action( "admin_menu", "addToMenu" );
}
function addToMenu()
{
//Main menu
add_plugins_page( "My Plugin", "My Plugin", "administrator", "my-plugin", "handlePlugin" );
//Sub Menu
add_submenu_page( "my-plugin", "test", "test", "administrator", "my-sub-slug", "handleSub" );
}
上面添加了“我的插件”,但没有添加“测试”子菜单。我做错了什么?默认情况下,Wordpress不允许使用三级菜单项。需要代码来改变Wordpress菜单的工作方式,以允许这样做。解决方法是将项目放在顶层,而不是放在插件下