Control Your Dashboard Widgets

When you log in to your WordPress blog you are automatically redirected to the Dashboard area - an area displaying various widgets, each containing useful information such as Right Now, Recent Comments and Incoming Links to name a few. What if you wanted to disable some or all of them?

One option is to click the Screen Options button at the top of the page which reveals all available dashboard widgets, each with a nifty check box beside its name. Simply unchecking the appropriate box will hide the widget from your Dashboard. To re-enable it tick the box. See screen shot below. (click image to enlarge)

dashboard_widgets

But what if, for some reason, you want to completely disable one or more widgets as opposed to hiding them? Sure you can do so by hacking core files but this is not recommended. A better option is to add a bit of code to your theme's functions.php file.

First, let's take a look at what the Codex has to say about Dashboard Widgets. Here are the names of the meta boxes on the dashboard:

Main column
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']

Side Column
$wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']
$wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']
$wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']
$wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']

To remove select items we will manually unset() their items from the general $wp_meta_box array via the theme's functions.php file.

Using the example provided by the Codex, to remove the quickpress and incoming_links widgets, add the following to your theme's functions.php file,

// Create the function to use in the action hook

function example_remove_dashboard_widgets() {
	// Globalize the metaboxes array, this holds all the widgets for wp-admin

	global $wp_meta_boxes;

	// Remove the quickpress widget

	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);

	// Remove the incomming links widget

	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
}

// Hoook into the 'wp_dashboard_setup' action to register our function

add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );

Look at the above carefully. Recall that the meta box for the quick_press widget is...

$wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']

See how we manually remove it via unset() as such...

unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);

You can follow this example to disable each of the widgets. In a local install I disabled all dashboard widgets. See the screen shot below. (click image to enlarge)

widgets_disabled

I accomplished this by making use of the info earlier in this post then by adding the following to my theme's functions.php file...

// Create the function to use in the action hook

function example_remove_dashboard_widgets() {
	// Globalize the metaboxes array, this holds all the widgets for wp-admin

	global $wp_meta_boxes;

	// Remove the quickpress widget

	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);

	// Remove the recent drafts widget

	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);

	// Remove the wordpress dev blog widget

	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);

	// Remove the other wp news widget

	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);

	// Remove the incomming links widget

	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);

	// Remove the dashboard right now widget

	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);

	// Remove the recent comments widget

	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);

	// Remove the plugins widget

	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
}

// Hoook into the 'wp_dashboard_setup' action to register our function

add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );

To re-enable any of the widgets simply remove the appropriate code from the functions.php file. To re-enable all of them remove all of the code.

Further reading: http://codex.wordpress.org/Dashboard_Widgets_API

post
About Len Kutchma

Len has been blogging for over 10 years and is a rabid WordPress fan. In addition to blogging here you can find him writing the occasional article and toiling away in the forums at WeblogToolsCollection.com. He also hangs out at the WordPress support forums lending a hand where he can. Be sure to follow @wpcanada on Twitter.

Comments

  1. Tanner Campbell says:

    PERFECT. This was hard to find but worth it. It's a perfect fix. However I have one thing I can't figure out -- how can I remove the Yoast widget -- I've tried everything, I can't stand it. Any help?

  2. Len Kutchma says:

    Hi Tanner,

    Where does this widget come from? Is it part of a theme?

  3. Adrian says:

    No, it's not a theme - it's a particularly powerful plugin - which is great and wonderful and all and I'm very grateful to the author, but I too would like to remove the whopping great advert widget as I don't need every one of my clients to have it take up so much screen real estate!

    It does seem impervious to most of the dashboard management plugins, and to the functions.php edits outlined above. I'm guessing it's not a $wp_meta_box, but maybe uses some sort of pseudo-metabox?!

    Anyway, it would be great if you can shed any light,

    thanks,

    Adrian

  4. Adrian says:

    Sorry, that comment is regarding the Yoast widget and should have been threaded - apologies :)

  5. Adrian says:

    Re my earlier comment (about the v useful but slightly too 'in your face' Yoast SEO widget) - I wasn't able to use the plug-in listed here - http://wordpress.org/extend/plugins/yoast-remove/ - but by placing the relevant code from that directly into the functions file - bingo!

    If Joost is reading this - no offence, it's only that the widget is _too_ prominent.

  6. Jason says:

    Thanks, great article. This will come in handy. Does it work with the latest version of WordPress?

  7. ryscript says:

    thanks for sharing will try this one on my site.

Please Note: WPCanada is a moderated community. Please read the Comment Policy.

Trackbacks

  1. [...] This post was mentioned on Twitter by Leland and Mark McWilliams, WordPress Canada. WordPress Canada said: WordPress Canada new post: Control Your Dashboard Widgets http://ow.ly/LLlX #wordpress [...]

What Do You Think?

*