Skip to content

Remove Core Menu Items in Dashboard

By Jasper Frumau

To remove unwanted items from the WordPress Dashboard that are part of the menu you can add the following code to the functions.php of your theme.

function img_remove_menus () {
 global $menu; // Make the menu variable global in scope
 $restricted = array( __('Posts'), __('Links'),__('Comments'), __('Tools'));
 end ($menu); // get final array value
 while (prev($menu)){ //check for previous value
 $value = explode(' ',$menu[key($menu)][0]);
 if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){
 unset($menu[key($menu)]); //
 }
 }
 }

add_action('admin_menu', 'img_remove_menus'); // add the action for removing the unwanted menu items