There are many reasons why you want to lessen the menus on the backend of WordPress. Some of these are

  • To make the backend as minimal as possible.
  • To make your theme design secure. You don’t want other administrator to edit it and mess around with it.
  • You just feel like other features are not needed.

There are still other more reasons as to why we do it, nonetheless, see the snippet code that you can use for this below.

Create a function that looks like this. This sample and the code is very verbose and by simply looking into it I think you can understand already what it does.

function remove_admin_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( 'themes.php' ); // Appearance 
        remove_menu_page( 'plugins.php' ); // Plugins 
        remove_menu_page( 'users.php' ); // Users 
        remove_menu_page( 'options-general.php' ); // Settings 
        remove_menu_page( 'edit-comments.php' ); /** Comments */
        remove_menu_page( 'tools.php' ); /** Tools */
}

After that you need to hook into for WordPress to be able to properly run the function.

add_action( 'admin_init', array( $this, 'remove_admin_menus' ), 11 );

That’s it! You can add different kind of conditional statement inside the function, depending on the needed requirements.

Written by Christian B.

I'm a web developer and programmer from Philippines. I have a diverse set of skills ranging from PHP, Laravel, Wordpress and many more. I believe in innovation and it is my passion, whether a project is a small or big - for me, every website deserves to be interactive and have the best web presence.