Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法在wordpress的插件菜单下添加子菜单_Php_Wordpress - Fatal编程技术网

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菜单的工作方式,以允许这样做。解决方法是将项目放在顶层,而不是放在插件下