Remove Menus From the WordPress Dashboard

If you want to hide specific menus from the WordPress dashboard, are you looking for a simple way? Then you are in the right place! I have searched in the WordPress plugin directory and found some plugins available. For such a simple task I didn’t prefer to use a plugin. You can implement this quickly even if you haven’t better coding knowledge. So let’s get started!

WordPress has a function that you can hide the menu simply.

remove_menu_page( $menu_slug )

Replace the menu slug with the name of the PHP file for the menu item you want to remove. For example: remove_menu_page( 'index.php' );// To Remove Dashboard

Parameters:

$menu_slug (string) (Required) The slug of the menu.

Removes every menu for all users. To remove only certain menu items include only those you want to hide within the function. To remove menus for only certain users you may want to utilize current_user_can().

Go to your theme/child-theme functions.php file and add following code.

/**
 * Removes some menus by page.
 */
function tsh_remove_menus(){
  remove_menu_page( 'edit.php?post_type=page' );    //Pages
  remove_menu_page( 'tools.php' );                  //Tools
  remove_menu_page( 'options-general.php' );        //Settings
   
}
add_action( 'admin_menu', 'tsh_remove_menus' );

The ‘Pages’, ‘Tools’, and ‘Settings’ should now be removed from the WordPress admin menu!

That’s it 🙌

If you have any query then please let me know in the comments section. I have checked this code with WordPress latest version. If you think this post saved your time, please subscribe to our newsletter for regular updates.

Happy coding 🙂

Thank you in advance!

Leave a Reply

Your email address will not be published. Required fields are marked *