How to Disable Dashboard Widgets in WordPress

Home » Snippets » How to Disable Dashboard Widgets in WordPress
0

Created with:

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

If you’re a WordPress user, you’re probably familiar with the dashboard – the central hub where you manage your site’s content, settings, and overall appearance. By default, the WordPress dashboard comes with a set of widgets that provide you with valuable information and quick access to various features. However, not all users find these widgets useful or necessary for their workflow. If you’re one of those users, you’ll be happy to know that you have the option to disable dashboard widgets and declutter your workspace. In this article, we’ll show you how to easily disable and remove unwanted widgets from your WordPress dashboard.

					function wpturbo_disable_dashboard_widgets() {
    // Remove "Welcome" panel
    remove_action('welcome_panel', 'wp_welcome_panel');

    // Remove "At a Glance" widget
    remove_meta_box('dashboard_right_now', 'dashboard', 'normal');

    // Remove "Activity" widget
    remove_meta_box('dashboard_activity', 'dashboard', 'normal');

    // Remove "Quick Draft" widget
    remove_meta_box('dashboard_quick_draft', 'dashboard', 'side');

    // Remove "WordPress News" widget
    remove_meta_box('dashboard_primary', 'dashboard', 'side');

    // Remove "Plugins" widget
    remove_meta_box('dashboard_plugins', 'dashboard', 'normal');

    // Remove "Recent Comments" widget
    remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');

    // Remove "Recent Drafts" widget
    remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side');

    // Remove "WordPress Events and News" widget
    remove_meta_box('dashboard_secondary', 'dashboard', 'normal');
}
add_action('wp_dashboard_setup', 'wpturbo_disable_dashboard_widgets');
				

The code snippet provided above demonstrates how to disable specific dashboard widgets in WordPress. This can be useful if you want to declutter the WordPress admin dashboard and remove unnecessary or distracting widgets.

The wpturbo_disable_dashboard_widgets() function is defined at the beginning of the snippet. Inside this function, we make use of the remove_meta_box() function to disable specific dashboard widgets.

Each call to remove_meta_box() consists of three parameters:

  1. The first parameter is the ID of the widget to be removed. This ID corresponds to the unique identifier of the widget being targeted.

  2. The second parameter is the slug of the dashboard page. In this case, we’re targeting the main dashboard page, so we use the dashboard slug.

  3. The third parameter is the context of the widget. This refers to where the widget is positioned on the dashboard. The values normal and side are used to remove widgets from the main content area and the sidebar, respectively.

By using multiple calls to remove_meta_box(), we can easily target and disable specific widgets. In the provided snippet, we disable several commonly seen dashboard widgets, such as the "Welcome" panel, "At a Glance," "Activity," "Quick Draft," "WordPress News," "Plugins," "Recent Comments," "Recent Drafts," and "WordPress Events and News."

Once all the calls to remove_meta_box() have been made, we hook the wpturbo_disable_dashboard_widgets() function into the wp_dashboard_setup action using the add_action() function. This ensures that the function is executed when the WordPress dashboard is being setup.

In conclusion, by using the provided code snippet and customizing the calls to remove_meta_box(), you can easily disable specific dashboard widgets in WordPress to create a more focused and organized admin dashboard experience.

Register an account to save your snippets or go Pro to get more features.