Family Encyclopedia >> Electronics

How to remove widgets from WordPress Dashboard

Have you ever worked on a project that required you to customize the display of the WordPress admin panel? Well, one of the first things consultants customize is the WordPress Dashboard. Here's a quick example of how to add custom dashboard widgets in WordPress. In this article, we will show you how to remove WordPress dashboard widgets.

Note:If you ended up in this article looking for how to remove dashboard widgets just for you, then you should probably check out our article:How to Customize WordPress Admin Area (Dashboard) for Beginners.

All you have to do is simply paste the following code into your theme's functions.php file. Although it might be a good idea to save this file as a plugin and make it an insert plugin.

 función remove_dashboard_widgets () global $ wp_meta_boxes; unset ($ wp_meta_boxes ['dashboard'] ['side'] ['core'] ['dashboard_quick_press']); unset ($ wp_meta_boxes ['dashboard'] ['normal'] ['core'] ['dashboard_incoming_links']); unset ($ wp_meta_boxes ['dashboard'] ['normal'] ['core'] ['dashboard_right_now']); unset ($ wp_meta_boxes ['dashboard'] ['normal'] ['core'] ['dashboard_plugins']); unset ($ wp_meta_boxes ['dashboard'] ['normal'] ['core'] ['dashboard_recent_drafts']); unset ($ wp_meta_boxes ['dashboard'] ['normal'] ['core'] ['dashboard_recent_comments']); unset ($ wp_meta_boxes ['dashboard'] ['side'] ['core'] ['dashboard_primary']); unset ($ wp_meta_boxes ['dashboard'] ['side'] ['core'] ['dashboard_secondary']); add_action ('wp_dashboard_setup', 'remove_dashboard_widgets'); 

Each of the widgets listed above are pretty self explanatory. You can keep the ones you want by simply removing them from the list. If you want to remove these widgets from all users except admins, just change the last line to this:

 if (! current_user_can ('manage_options')) add_action ('wp_dashboard_setup', 'remove_dashboard_widgets'); 

We hope this article helped you remove default dashboard widgets in WordPress.