Languages: English • 日本語 (Add your language)
Remove an admin submenu.
Depending on when this function is called, it may not prevent users from accessing the screen for the removed submenu directly (see ticket #18850). Removing a menu does not replace the need to filter a user's permissions as appropriate.
<?php remove_submenu_page( $menu_slug, $submenu_slug ); ?>
Removes the Widgets submenu page.
function wpcodex_adjust_the_wp_menu() { $page = remove_submenu_page( 'themes.php', 'widgets.php' ); // $page[0] is the menu title // $page[1] is the minimum level or capability required // $page[2] is the URL to the item's file } add_action( 'admin_menu', 'wpcodex_adjust_the_wp_menu', 999 );
In the above example, the value of $page would have been:
array(3) { [0]=> string(7) "Widgets" [1]=> string(18) "edit_theme_options" [2]=> string(11) "widgets.php" }
To remove a settings page for plugins that use a slug like /wp-admin/options-general.php?page=certain-plugin-settings use this code:
add_action( 'admin_menu', 'nstrm_remove_admin_submenus', 999 ); function nstrm_remove_admin_submenus() { remove_submenu_page( 'options-general.php', 'certain-plugin-settings' ); }
Remove custom post type submenu pages. The secret is in converting the second argument `&` to `&`.
Since: 3.1.0
remove_submenu_page() is located in /wp-admin/includes/plugin.php
.
Administration Menus: add_menu_page(), remove_menu_page(), add_submenu_page(), remove_submenu_page(), add_dashboard_page(), add_posts_page(), add_media_page(), add_links_page(), add_pages_page(), add_comments_page(), add_theme_page(), add_plugins_page(), add_users_page(), add_management_page(), add_options_page()