By
05/13/2016   Comments Off on Remove admin menu items from WordPress

View all snippets

Add and alter the highlighted items to whatever admin pages you want to hide. This removes them for all users. For more flexibility and less coding, use a plugin.

function remove_admin_menu_items() {
 $remove_menu_items = array(__('Links'),__('Posts'),__('Comments'));
 global $menu;
 end ($menu);
 while (prev($menu)){
 $item = explode(' ',$menu[key($menu)][0]);
 if(in_array($item[0] != NULL?$item[0]:"" , $remove_menu_items)){
 unset($menu[key($menu)]);}
 }
 }
 
 add_action('admin_menu', 'remove_admin_menu_items');