Reading list Switch to dark mode

    How to remove Admin Menu item in WordPress

    Updated 18 September 2023

    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 ?
    Read 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.

    References

    https://developer.wordpress.org/reference/functions/remove_menu_page/
    https://developer.wordpress.org/reference/functions/remove_submenu_page/
    https://developer.wordpress.org/reference/functions/unregister_post_type/

    !!Have a Great Day Ahead!!

    . . .
    Discuss on Helpdesk

    Leave a Comment

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


    7 comments

  • Krishna Ingrassia
    I just added your RSS Feed on my RSS reader, it is so nice to read your blog.;:`;*
  • Maria Tamburro
    Aw, this is quite a good post. In thought I would like to invest writing this way moreover – taking time and actual effort to have a very good article… but what can I say… I procrastinate alot through no means manage to go done.
  • Elwanda Veness
    After study a few of the blog articles with your site now, and that i genuinely as if your means of blogging. I bookmarked it to my bookmark website list and are checking back soon.
  • Clemencia Kozel
    Hi there, I discovered your site by the use of Google at the same time as searching for a comparable subject, your web site got here up, it appears great. I have bookmarked it in my google bookmarks.
  • Jeromy Hendrie
    Deference to op , some superb selective information .
  • Billy
    Very Helpful
  • Aakash
    Really helpfull it resolve my problem
  • 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