Removing menu pages from the WordPress admin
In this tutorial, I’ll cover the remove_menu_page() and remove_submenu_page() functions, which were added in WordPress 3.1.
The first thing you need to decide is where you’re putting the code. I’ll assume you’re either dropping this in your theme’s
The first thing you need to decide is where you’re putting the code. I’ll assume you’re either dropping this in your theme’s
functions.php
file or one of your plugin files.1. Removing top-level menu pages
Usage
remove_menu_page( $menu_slug );
Examples
<?php
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'options-general.php' ); //Settings
}
add_action( 'admin_menu', 'remove_menus' );
?>
2.
Removing sub-menu pages
Usage
remove_submenu_page( $parent_slug, $menu_slug );
Examples
<?php
function remove_menus(){
remove_submenu_page( 'themes.php', 'customize.php' );
}
add_action( 'admin_menu', 'remove_menus' );
?>
Comments
Post a Comment