Add remove WordPress dashboard widgets

Add remove Wordpress dashboard widgets

WordPress comes with a bunch of widgets loaded on its dashboard. The default WordPress dashboard may seems cluttered to some users because many widgets may be irrelevant for them. Such users can easily clean their dashboard.

By using wp_dashboard_setup hook you can add/remove widgets from dashboard as shown below.

	function example_remove_dashboard_widgets() 
	{
		// Globalize the metaboxes array, this holds all the dashboard widgets
		global $wp_meta_boxes;

		// Remove the incomming links widget
		unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);

		// Remove right now
		unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
		unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
		unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
	}

	// Hoook into the 'wp_dashboard_setup' action to register our function
	add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets');
	add_action('wp_dashboard_setup', 'example_add_dashboard_widgets');

	function example_add_dashboard_widgets() 
	{
		wp_add_dashboard_widget('example', 'Example', 'example_widget_callback');
	}

	function example_widget_callback() 
	{
		echo 'Its a custom widget!';
	}

Author: Tahir Yasin

Tahir is a Passionate Web Developer from Lahore, Pakistan and a guy with NEVER-STOP-LEARNING attitude who keeps an eye on emerging technologies and customer trends.

3 thoughts on “Add remove WordPress dashboard widgets”

  1. i have recently taken over as an administrator for a school website which was recently developed (at a ridiculous price by a dreadful developer.) and i am trying to fix the mess we have been left with. the problem is that i have an admin account but cannot change the theme, header, widgets, create templates etc. as they dont appear on the tool bar under appearance. when i change theme it does work but not with this one, i think the developer has locked it somehow and they are being very difficult and not unlocking it without a fight, is there anyway that i could unlock it.

    1. You must be using a limited account. To verify if you have administrator role & rights. First find your user ID in wp_users table and then run below query

       SELECT meta_value FROM wp_usermeta WHERE meta_key='wp_user_level' AND user_id = x 

      where x is your user_id that you taken from wp_users table.

      If you are administrator then above query must return 10 otherwise you are not an administrator.

Leave a Reply

Your email address will not be published. Required fields are marked *