Metabox Tutorial – Remove a Dashboard Widget

The widgets screen in WordPress shows you all the widgets that you can add to your theme. The problem is that too many widgets clutter the screen, and you may not need all of them.

Do you want to remove dashboard widgets?

We have several options available in wordpress which removes dashboard widgets.

  • Screen options
  • Using Code scripts
  • Using Third party plugin

We will see first two options.

Screen options

At wordpress admin dashboard, find Screen Options at top of screen.

If widgets checkboxes checked means that widget will be shown else it will be temporarily hidden.

Using Code scripts

In wordpress everything we can control by using action hooks and filters. So to remove dashboard widget also we have a action hook available.

Site Health Status, At a Glance, Quick Draft, Activity, and WordPress Events and News are five WordPress dashboard widgets you can see on the dashboard when you log in to your WordPress website.

To remove these,

/*
* Remove dashboard widgets
*/
function remove_dashboard_widgets()
{
    global $wp_meta_boxes;

    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_site_health']);
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
}

add_action('wp_dashboard_setup', 'remove_dashboard_widgets');

Above code will remove dashboard widgets. You can add this code into your custom plugin code or add inside activated theme functions.php file.

dashboard_site_health, dashboard_quick_press, dashboard_activity, dashboard_right_now, dashboard_primary are widget IDs.

To remove custom widget, simply you need to use your widget id here.

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

Sanjay KumarHello friends, I am Sanjay Kumar a Web Developer by profession. Additionally I'm also a Blogger, Youtuber by Passion. I founded Online Web Tutor and Skillshike platforms. By using these platforms I am sharing the valuable knowledge of Programming, Tips and Tricks, Programming Standards and more what I have with you all. Read more