你好@JM at Work:
是的,很遗憾,每个菜单页都添加了子菜单页。那太好了if there were an option but alas, there currently is not.
要删除WordPress 3.1中的子菜单页选项,请使用remove_submenu_page()
在主题的functions.php
文件,或在.php
您可能正在编写的插件的文件:
add_action( \'admin_menu\', \'yoursite_admin_menu\' );
function yoursite_admin_menu() {
add_menu_page( \'Forms\', \'Forms\', \'administrator\', \'forms\', \'forms_job_menupage_cb\' );
add_submenu_page( \'forms\', \'Job Applications\', \'Job Applications\', \'administrator\', \'job-applications\', \'forms_job_menupage_cb\' );
add_submenu_page( \'forms\', \'Quote Requests\', \'Quote Requests\', \'administrator\', \'quote-req\', \'forms_req_menupage_cb\' );
add_submenu_page( \'forms\', \'Contact\', \'Contact\', \'administrator\', \'contact\', \'forms_contact_menupage_cb\' );
remove_submenu_page(\'forms\',\'forms\');
}
如果您仍在使用WordPress 3.0,则必须
unset()
全局变量的元素
$submenu
像这样:
add_action( \'admin_menu\', \'yoursite_admin_menu\' );
function yoursite_admin_menu() {
add_menu_page( \'Forms\', \'Forms\', \'administrator\', \'forms\', \'forms_job_menupage_cb\' );
add_submenu_page( \'forms\', \'Job Applications\', \'Job Applications\', \'administrator\', \'job-applications\', \'forms_job_menupage_cb\' );
add_submenu_page( \'forms\', \'Quote Requests\', \'Quote Requests\', \'administrator\', \'quote-req\', \'forms_req_menupage_cb\' );
add_submenu_page( \'forms\', \'Contact\', \'Contact\', \'administrator\', \'contact\', \'forms_contact_menupage_cb\' );
unset($GLOBALS[\'submenu\'][\'forms\'][0]);
}