How to completely remove the main menu in the WordPress admin panel
The code below will be useful if you need to completely remove the main menu in the WordPress admin panel, while still allowing access to pages/menu items through direct links.
add_action( 'admin_head', 'kill_adminmenu' ); function kill_adminmenu() { $GLOBALS['menu'] = array(); echo ' <style> #adminmenuwrap, #adminmenuback{ display:none !important; } #wpcontent{ margin-left:10px !important; } </style> '; }
Insert the code into the functions.php file and the menu will no longer be displayed in the admin panel. The menu is visually removed and does not block access to menu items through direct links.
Result: