Like the blog? Get the book »

Disable Default Dashboard Widgets in WordPress

Disable Default Dashboard Widgets in WordPress

Continuing with tips for customizing the WordPress Dashboard, here is a look at one way to remove unwanted widgets and clean up the default WP Dashboard.

Using WordPress to build sites like Plugin Planet, it's usually necessary to customize the Dashboard by removing some default widgets and adding some of my own. No big deal, but the code required to disable the default widgets seems to evolve along with WordPress.

So if you have any sites where you've disabled default dashboard widgets, it may be worthwhile to check that the code is still working. Either way, here is a function that works great with current WordPress (3.8):

Update: added lines to disable dashboard widgets for Yoast SEO and Gravity Forms.
	Disable Default Dashboard Widgets
function disable_default_dashboard_widgets() {
	global $wp_meta_boxes;
	// wp..
	// bbpress
	// yoast seo
	// gravity forms
add_action('wp_dashboard_setup', 'disable_default_dashboard_widgets', 999);

When added to the theme's functions.php file, this code will disable all default widgets in the WP Dashboard. It's drastic, so be sure to comment-out or remove any lines that aren't required.

The code itself is straightforward, basically a function that uses unset to disable the default widgets, "Recent Activity", "Right Now", and so forth. Note that the last line in the function is to disable the default bbPress widget (remove if not needed). Lastly the function is hooked into WordPress via wp_dashboard_setup.

That's all there is to it, just add the code to your theme's functions file (or plugin or whatever) and done. At least, until things change again.


The old way uses remove_meta_box() for each widget, for example:

remove_meta_box('dashboard_right_now', 'dashboard', 'core');
remove_meta_box('dashboard_recent_comments', 'dashboard', 'core');
remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');
remove_meta_box('dashboard_plugins', 'dashboard', 'core');
remove_meta_box('dashboard_quick_press', 'dashboard', 'core');
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'core');
remove_meta_box('dashboard_primary', 'dashboard', 'core');
remove_meta_box('dashboard_secondary', 'dashboard', 'core');

I've seen other techniques as well, but I think with 3.8 going the unset methodology seems the way to go.

6 responses

  1. Great tip. Worked perfectly. I love to have my WordPress Dashboard clean and tidy so this was right up my street.

  2. why is using global variables considered a better way? remove_meta_box seems much nicer and cleaner. are there any reasons the long and less readable unset $wp_meta_boxes... code should be used?

  3. Awesome tip, worked perfectly. Thanks!

  4. For the copy and pasters out there… there is an extraneous apostrophe within ['yoast_db_widget'']. Otherwise, great tip. Thanks!

Comments are closed for this post. Contact us with any critical information.
© 2009–2021 Digging Into WordPress Powered by WordPress Monzilla Media shapeSpace