Remove the whole menu in the admin

How can i remove the whole menu in the admin?

I have this code:

Read More
function remove_menu_items() {
    global $menu;

    end( $menu );

    while ( prev($menu) ) {
        $value = explode( ' ', $menu[ key($menu) ][0] );
        if ( $value[0] != NULL ? $value[0] : "" ) {
            unset( $menu[ key($menu) ] );
        }
    }
}
add_action( 'admin_menu', 'remove_menu_items' );

This only removes the default menu items, any pages added to the menu by a plugin are still there.

How can i remove the whole menu?

Related posts

Leave a Reply

3 comments

  1. add_action('admin_head', 't5_hide_menu');
    function t5_hide_menu()
    {
        $GLOBALS['menu'] = array();
        ?>
    <style>#adminmenuback,#adminmenuwrap{display:none !important}
    #wpcontent, #footer{margin-left:0 !important}</style>
    <?php
    }
    

    Now I want to know: why? 🙂

  2. Use the following to remove the entire thing:

    global $menu;
    unset($menu);
    

    Hope this helps!

    Btw, the admin menu code is in /wp-admin/menu.php if you want to look at it and mess with certain items.

  3. You could use CSS:

    #adminmenuwrap { display:none; }
    

    Or you could use Javascript and hide each element.

    Target #menu-media, #menu-links and so on.


    Or you could do this:

    add_action( 'admin_menu' , 'i_can_haz_no_menuz' );
    function i_can_haz_no_menuz() {
        global $menu;
        $menu = array();
    }
    

    Just remember that other plugins may add menus after this point.