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

About the author
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. You can also find him at his other blog LenKutchma.com

6 Responses to “Control Your Dashboard Widgets”

  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 [...]

  2. 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?
    Tanner Campbell´s last blog ..Transient AmericaMy ComLuv Profile

  3. Len Kutchma says:

    Hi Tanner,

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

Leave a Reply

CommentLuv Enabled