Reading list Switch to dark mode

    How to remove Admin Menu item in WordPress

    Updated 15 February 2024

    WordPress is full of fun things, we can manipulate the things according to our needs from the dashboard to prevent user get confused. We seen, how to add Menu and Submenu in WordPress admin panel in our previous blog. WordPress admin dashboard full with lots of menu and submenu like Dashboard, Media, Post, Page, Comment, Appearance, Plugins, User and many more. In some scenario we need to remove the menu from the admin panel like you dont need 3rd party plugin menu either default menu

    Function for remove menu item

    remove_menu_page( string $menu_slug )

    This will removes a top-level admin menu.

    Example usage:

    • remove_menu_page( 'tools.php' )
    • remove_menu_page( 'plugin_menu_slug' )

    Searching for an experienced
    WordPress Company ?
    Find out More

    Parameters

    $menu_slug string Required

    The slug of the menu.

    Return value

    array|false The removed menu on success, false if not found.

    Example

    Remove contact form 7 menu from admin panel

    add_action( 'admin_init', function () {
        remove_menu_page( 'edit.php?post_type=participants-database' );
        //OR
        remove_menu_page( 'wpcf7' );
    });

    Remove Menu items by page

    /**
     * Removes some menus by page.
     */
    if ( ! function_exists( 'deregister_post_type' ) ) {
     function wpdocs_remove_menus(){
       remove_menu_page( 'index.php' );                  //Dashboard
       remove_menu_page( 'jetpack' );                    //Jetpack* 
       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', 'wpdocs_remove_menus' );
    ?>

    do_action( ‘admin_init’ )

    Fires as an admin screen or script is being initialized. ( admin_init is fires before any other hook when a user accesses the admin arena.)

    Additional

    Remove post type from wordpress

    Suppose we have a registered post type named “blog” and need to remove this from the admin panel then just follow these codes.

    add_action( 'init', 'deregister_post_type' );
    if ( ! function_exists( 'deregister_post_type' ) ) {
    	function deregister_post_type() {
    		unregister_post_type( 'blog' );
    	}
    }

    do_action( ‘init’ )

    This will fires after WordPress has been finished the loading but before any headers are sent.
    remove-post-type

    Remove submenu page items

    remove_submenu_page( 'plugin_menu_slug', 'plugin_submenu_slug' )

    /**
     * Remove the Widgets submenu page.
     */
    function remove_the_wp_menu() {
    	$page = remove_submenu_page( "edit.php?post_type=blog", 'add-new' );
    }
    add_action( 'admin_menu', 'remove_the_wp_menu', 999 );

    add_action -> Add a callback function to your action hook.

    admin_menu -> Fires earlier than the admin menu is loaded in Admin

    add_action -> admin_menu

    If you need custom WordPress Development services then feel free to reach us and also explore our exclusive range of WordPress WooCommerce Plugins.

    !!Have a Great Day Ahead!!

    . . .

    Leave a Comment

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


    3 comments

  • Jeromy Hendrie
  • Billy
  • Aakash
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home

    Table of Content