The WordPress dashboard includes several built-in widgets that provide quick access to site activity, drafts, comments, updates, and other administrative information. While these widgets can be useful, a dashboard with too many unnecessary elements can become cluttered, especially for clients, editors, subscribers, or users who only need access to specific features.
Fortunately, WordPress provides hooks and functions that developers can use to add or remove dashboard widgets programmatically. In this guide, you will learn how to remove unwanted WordPress dashboard widgets and create your own custom dashboard widget using the wp_dashboard_setup action.
Why Customize the WordPress Dashboard?
The default WordPress dashboard is designed to work for a wide range of websites. However, the default widgets may not always be relevant to a particular project or user.
Customizing the dashboard can help you:
- Remove unnecessary dashboard widgets.
- Create a cleaner WordPress admin interface.
- Display project-specific information.
- Give clients a simpler administration experience.
- Add useful shortcuts or custom content for administrators.
- Show important website information directly on the dashboard.
How to Remove WordPress Dashboard Widgets
WordPress provides the wp_dashboard_setup action, which can be used to modify the dashboard after the default widgets have been registered.
One approach is to remove specific dashboard widgets from the global $wp_meta_boxes array.
Remove a Specific Dashboard Widget
For example, the following code removes the WordPress Quick Draft widget:
function example_remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
}
add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets');
Add this code to a suitable custom plugin or your theme's functionality file. Using a custom plugin is generally preferable when the functionality should remain active even if the website's theme changes.
Remove Multiple WordPress Dashboard Widgets
You can remove multiple widgets in the same function by calling unset() for each widget you no longer need.
function example_remove_dashboard_widgets() {
global $wp_meta_boxes;
unset(
$wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'],
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity'],
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']
);
}
add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets');
The exact widget IDs depend on which dashboard widgets you want to remove. When customizing an existing WordPress installation, check the widget registration and ID before removing it.
How to Add a Custom WordPress Dashboard Widget
WordPress also provides the wp_add_dashboard_widget() function for registering a custom dashboard widget.
The basic structure looks like this:
function example_add_dashboard_widgets() {
wp_add_dashboard_widget(
'example_dashboard_widget',
'Example',
'example_widget_callback'
);
}
function example_widget_callback() {
echo '<p>This is a custom WordPress dashboard widget.</p>';
}
add_action('wp_dashboard_setup', 'example_add_dashboard_widgets');
In this example, wp_add_dashboard_widget() registers a widget with a unique ID, a title, and a callback function. WordPress then calls the callback function when the widget needs to be displayed.
Understanding wp_add_dashboard_widget()
The function accepts several arguments. The basic usage is:
wp_add_dashboard_widget( $widget_id, $widget_name, $callback);
- $widget_id: A unique identifier for your dashboard widget.
- $widget_name: The title displayed at the top of the widget.
- $callback: The function that generates the widget's content.
For example:
wp_add_dashboard_widget( 'website_information', 'Website Information', 'website_information_callback');
Creating a More Useful Custom Dashboard Widget
A custom widget does not have to contain simple text. You can use it to display useful information relevant to your WordPress project.
For example, a dashboard widget could display links to important administrative pages:
function scriptbaker_dashboard_widget() {
echo '<h3>Quick Links</h3>';
echo '<ul>';
echo '<li><a href="' . esc_url(admin_url('edit.php')) . '">Manage Posts</a></li>';
echo '<li><a href="' . esc_url(admin_url('upload.php')) . '">Media Library</a></li>';
echo '<li><a href="' . esc_url(admin_url('edit-comments.php')) . '">Manage Comments</a></li>';
echo '</ul>';
}
function scriptbaker_add_dashboard_widget() {
wp_add_dashboard_widget(
'scriptbaker_quick_links',
'Quick Links',
'scriptbaker_dashboard_widget'
);
}
add_action('wp_dashboard_setup', 'scriptbaker_add_dashboard_widget');
This approach can make the WordPress dashboard more useful by putting frequently accessed resources in one place.
Remove Dashboard Widgets for Specific Users
In some WordPress projects, you may want to customize the dashboard differently depending on the user's role or capabilities.
For example, you can check whether the current user has administrator capabilities before removing or adding a widget:
function example_customize_dashboard() {
if ( ! current_user_can('manage_options') ) {
global $wp_meta_boxes;
unset(
$wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'],
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']
);
}
}
add_action('wp_dashboard_setup', 'example_customize_dashboard');
This can be useful when creating a simplified dashboard for clients or non-administrator users.
Dashboard Widgets vs. Screen Options
WordPress users can also control some dashboard widgets through the Screen Options panel at the top of the dashboard.
However, Screen Options are user-specific. If you need to programmatically control which widgets are available across a WordPress installation, using wp_dashboard_setup provides a developer-oriented solution.
Best Practices for WordPress Dashboard Customization
Use a Unique Widget ID
Always give custom widgets a unique ID to avoid conflicts with WordPress core, plugins, or other custom functionality.
Escape Output
When displaying dynamic URLs or user-generated data, use appropriate WordPress escaping functions such as esc_url() and esc_html().
Keep the Dashboard Useful
Removing too many widgets can make the dashboard less informative. Only remove widgets that are unnecessary for the users who access the dashboard.
Consider User Roles
A dashboard designed for an administrator may contain different information from one intended for an editor or client. Use WordPress capabilities when you need role-specific behavior.
Prefer a Custom Plugin for Site-Specific Functionality
If dashboard customization is part of the website's functionality rather than its visual design, consider placing the code in a custom plugin. This allows the functionality to remain available if the site's theme is replaced.
Common Uses for Custom WordPress Dashboard Widgets
Custom dashboard widgets can be useful in many types of WordPress projects. For example, developers can create widgets for:
- Internal administrative links.
- Website maintenance information.
- Custom project instructions.
- Important announcements.
- Content management shortcuts.
- Custom business information.
- Workflow reminders.
- Plugin-specific information.
Frequently Asked Questions
How do I remove a dashboard widget in WordPress?
You can remove a dashboard widget programmatically by using the wp_dashboard_setup action and unsetting the appropriate widget from the $wp_meta_boxes array. The widget's ID and dashboard context must match the registered widget.
What hook is used to customize WordPress dashboard widgets?
The wp_dashboard_setup action is commonly used to add or remove WordPress dashboard widgets during dashboard setup.
How do I add a custom widget to the WordPress dashboard?
Use the wp_add_dashboard_widget() function inside a function hooked to wp_dashboard_setup. The widget callback function is responsible for generating its content.
Can I remove WordPress dashboard widgets for specific users?
Yes. You can use WordPress capabilities such as current_user_can() to apply dashboard customization conditionally based on the current user's permissions.
Can I create a custom WordPress admin dashboard?
Yes. WordPress provides hooks and administrative APIs that developers can use to customize the dashboard, add custom widgets, modify admin functionality, and create a more tailored experience.
Should I add dashboard widget code to functions.php?
You can add the code to functions.php, but a custom plugin is often more appropriate for functionality that should remain active when the website theme changes.
Why should I customize the WordPress dashboard?
Dashboard customization can reduce unnecessary information, simplify the WordPress admin experience, and provide users with quick access to the tools and information they need.
Conclusion
Customizing the WordPress dashboard is a straightforward way to create a cleaner and more useful administration experience. With the wp_dashboard_setup action, you can remove unnecessary widgets, while wp_add_dashboard_widget() allows you to add custom functionality to the dashboard.
Whether you are building a client website, membership platform, content management system, or custom WordPress solution, dashboard customization can make everyday administration easier and more focused.
Last updated: