WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/remove submenu page

Contents

Description

Remove an admin submenu.

Please be aware that this would not prevent a user from accessing these screens directly. Removing a menu does not replace the need to filter a user's permissions as appropriate.

Usage

<?php remove_submenu_page$menu_slug$submenu_slug ); ?>

Parameters

$menu_slug
(string) (required) The slug for the parent menu
Default: None
$submenu_slug
(string) (required) The slug of the submenu
Default: None

Return Values

(array|boolean) 
The removed submenu on success, false if not found.

Examples

Removes the Widgets submenu page.

<?php

add_action( 'admin_menu', 'adjust_the_wp_menu', 999 );
function 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
}

?>

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" }

Remove custom post type submenu pages. The secret is in converting the second argument `&` to `&amp;`.

Notes

  • Uses global: (array) $submenu
  • In order to remove the theme-editor.php submenu of themes.php in more recent versions of WordPress, you need to bind the remove_submenu_page function to the admin_init hook.

Change Log

Since: 3.1.0

Source File

remove_submenu_page() is located in /wp-admin/includes/plugin.php.

Related

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()

See also index of Function Reference and index of Template Tags.