After having an interesting conversation with “Support” regarding an article titled, “How to Remove WordPress Dashboard Widgets” at wpbeginner.com, I decided to make public the code that was intentionally removed from my comments.
The first response from “Support” confused me, although, he was right, I did provide the incorrect URL. However, on the next comment, I provided the correct URL. The URL was removed, and he made it sound like I was referencing how to hide the dashboard widgets with the Screen Options tab in WordPress. I wasn’t referencing that feature. I know what I was talking about. I then realized that he might have been removing the links because he didn’t like that the links could direct people to others’ sites—competitors’ sites? So, instead, he made it sound like I was confused. Wow. Is that how support should treat a potential customer? Thanks WPBeginner Support. I know what I’m doing; and, Mr. WPBeginner Support, I know what you’re doing too. 🙂
Anyway, on to the fun bit!
I don’t use most of the WordPress dashboard widgets that come standard with WordPress. They tend to add unnecessary blocks of information to my screen, and I have to hide them each time I create a new site or add a new user.
Instead of repeating this task every time one of these scenarios occurs, why not remove them entirely within my plugin?
Here’s how to do it. WPBeginner showed an excellent way of doing this. Fast forward (90s kid terminology) 3 years, I found a better way of doing this utilizing the WordPress API.
Here’s the code in all its glory:
// disable default dashboard widgets
function disable_default_dashboard_widgets() {
//remove_meta_box('dashboard_right_now', 'dashboard', 'core');
remove_meta_box('dashboard_activity', 'dashboard', 'core');
remove_meta_box('dashboard_recent_comments', 'dashboard', 'core');
remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');
remove_meta_box('dashboard_plugins', 'dashboard', 'core');
remove_meta_box('dashboard_quick_press', 'dashboard', 'core');
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'core');
remove_meta_box('dashboard_primary', 'dashboard', 'core');
remove_meta_box('dashboard_secondary', 'dashboard', 'core');
}
add_action('admin_menu', 'disable_default_dashboard_widgets');
Source (Scroll about half-way down the page.)
Add the above code to the functions.php file in your theme’s directory, or add it to a custom plugin for use in multiple sites, and you’re done! Check out your new, improved, cleaner WordPress Dashboard, and bask in its refreshing beauty…and ease of use.
At least my conversation with WPBeginner Support led to my first blog “code” article! Thanks, WPBeginner. 😁
I agree with you. There are several sections or blocks on WordPress that users don’t need in normal cases. I disturb with them but couldn’t find any suitable solution yet.
Thanks for sharing the code. I will check it on my text site first followed by the main site. Cheers!
Take care,
Glad this article was a help, Manoj!