Skip to content

Instantly share code, notes, and snippets.

@SiGaCode
Last active October 6, 2017 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiGaCode/bdb9ab8fe9f0703e0d3e06bea3cb9f1b to your computer and use it in GitHub Desktop.
Save SiGaCode/bdb9ab8fe9f0703e0d3e06bea3cb9f1b to your computer and use it in GitHub Desktop.
Remove unwanted items from the WP admin sidebar. Useful if you don´t want to run any blog-related things on a site. Credit: https://managewp.com/wordpress-admin-sidebar-remove-unwanted-items #PHP #dashboard
/*-----------------------------------------------------------------------------------*/
/* Remove Unwanted Admin Menu Items */
/*-----------------------------------------------------------------------------------*/
function remove_admin_menu_items() {
// Edit only the following line to remove the items you don´t need
$remove_menu_items = array(__('Comments'),__('Posts'));
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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment