WordPress Trick: Remove Dashboard Widgets
Want to remove some dashboard widgets programmatically? Perhaps to hide useless cruft from every role but the Administrator? Dump this in your themes functions.php:
function remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
if (!current_user_can('manage_options')) {
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
}
This removes all dashboard widgets, so you’ll probably want to poke around and comment out some of these array unsets.
- How Eric Schmidt Lost His Mistress, His Partner And Steve Jobs
- WordPress Trick: Remove Dashboard Widgets
- Song of the Day
- Google Stops Censoring In China
Nice! Always wanted to implement this but never actually looked it up.
thanks.
Wrap this in a plugin and millions will love you ;-)
Will this speed WP up in any way? Or is it just a visual improvement?
It’s a visual change only. And it’s useful mostly to unclutter the wordpress interface for novice users.
huge tips, any one can to turn it to a plugin? :)
Nice tip!… Great for client projects.
Great post! Thanks.
Just one problem, I found that this code didn’t remove the ‘Recent Drafts’ widget and that this code is necessary instead:
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);