@JM,您好:
是的,不幸的是,为每个菜单页面添加了子菜单页面。这将是很好,如果有一个选项,但很可惜,目前还没有。
要删除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]);
}