wordpress disable/remove menu submenus

add_action( '_admin_menu', 'disable_category_menu');

function disable_category_menu () {
global $submenu;
if (is_site_admin()) {
} elseif(!empty($submenu['edit.php'])) {
foreach($submenu['edit.php'] as $key => $sm) {
if(__($sm[0]) == "Categories" || $sm[2] == "categories.php") {
if (!empty($submenu['themes.php'])) {
foreach($submenu['themes.php'] as $key => $sm) {
if(__($sm[0]) == "Themes" || $sm[2] == "themes.php") {
if (!empty($submenu['tools.php'])) {
foreach($submenu['tools.php'] as $key => $sm) {
if(__($sm[0]) == "Tools" || $sm[2] == "tools.php") {

function remove_menus () {
global $menu;
$restricted = array(__('Dashboard'), __('Posts'), __('Media'),
__('Links'), __('Pages'), __('Appearance'), __('Tools'),
__('Users'), __('Settings'), __('Comments'), __('Plugins'));
if (is_site_admin()) {
} else {
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){
add_action('admin_menu', 'remove_menus');

About Kapil Chugh

In love with PHP and tweaking WordPress. Hungry for Open Source and new technologies. Honest. God-fearing. Happiest when solving problems.
This entry was posted in WordPress and tagged . Bookmark the permalink.

17 Responses to wordpress disable/remove menu submenus

  1. Download Losing a few pounds: Getting started , a 12-week weight loss information that
    mixes advice on healthier consuming and bodily activity.

  2. I really like what you guys are usually up too. This
    type of clever work and reporting! Keep up the very good works guys I’ve
    you guys to my blogroll.

  3. Hello There. I discovered your blog the usage of msn.
    That is a very smartly written article. I’ll make sure to bookmark it and return to read extra of your helpful info.
    Thank you for the post. I will certainly return.

  4. Hello just wanted to give you a quick heads up and let you know a
    few of the images aren’t loading correctly. I’m not
    sure why but I think its a linking issue. I’ve tried it in two different internet browsers and both show the same results.

  5. bim says:

    hi, i think your code only hides unwanted menu but still can access the designated URL for these hidden menu. just sharing what i’ve encountered.

    • sebastien says:

      yes it is, you’re rigt, but it’s ok for me.🙂
      And for the menu “editor” do you know it’s possible to disable this menu ?

  6. sebastien says:

    Hi. I want to hide only the submenu “Editor” in “appearance”… this submenu is adding by this line :
    // Add ‘Editor’ to the bottom of the Appearence menu.
    add_action(‘admin_menu’, ‘_add_themes_utility_last’, 101);
    function _add_themes_utility_last() {
    // Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook
    add_submenu_page(‘themes.php’, _x(‘Editor’, ‘theme editor’), _x(‘Editor’, ‘theme editor’), ‘edit_themes’, ‘theme-editor.php’);

    what can i hide this submenu please ?

  7. I’m using F-8 lite, and my menu disappeared when I updated something! Do you know how to get it to re-appear?

  8. A. R. says:

    I am new to wordpress, so thank you for your help. Where do i put this code on my wordpress page in order to remove the horizontal submenus on my pages? Do the code have to go on each page that I would like to remove the submenu for?

  9. Apoorva Moghey says:

    Fantastic trick to disable menu & sub-menu.It helps me allot .
    Thanks Kapil

  10. Thanks for sharing this. Now I can selectively choose which multisite users can access certain sub-menus (for instance I’ve disabled themes for standard users). This saved me some time hunting around on the web.

  11. Kapil Chugh says:

    For that you need to unset submenus.I have given code to remove submenus as well.

  12. Dominic Penrice says:

    how do I use this to show only a one level down of sub menus? Or how do I not allow certain pages not to appear the in menu at all.

    Many thanks for your help.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s