Skip to content

Instantly share code, notes, and snippets.

@schutzsmith
Created April 14, 2019 05:10
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 schutzsmith/29947a96b5d137ce5fd5340e62ad5429 to your computer and use it in GitHub Desktop.
Save schutzsmith/29947a96b5d137ce5fd5340e62ad5429 to your computer and use it in GitHub Desktop.
Remove unnecessary dashboard widgets in WordPress
// remove unnecessary dashboard widgets
function remove_dashboard_widgets(){
global $wp_meta_boxes;
// only remove "Right Now" for non-administrators
if (!current_user_can('activate_plugins')) {
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
}
// remove widgets for everyone
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment