How to Remove Widgets from the WordPress Dashboard

The available widgets on the WordPress dashboard are all useful, but oftentimes we do not use all of them and their presence overwhelms us. A lot of custom theme creators even limit the number of widgets shown on the dashboard to whatever are really necessary for the website that they are designing. Some even remove them altogether and create their own widgets!

If you find yourself in such a situation and you want to remove or unregister all the widgets, open the functions.php file of your WordPress theme and add the following lines of code in it:

// Remove default WordPress widgets
function remove_default_widgets() {
unregister_widget('WP_Widget_Pages');
unregister_widget('WP_Widget_Calendar');
unregister_widget('WP_Widget_Archives');
unregister_widget('WP_Widget_Links');
unregister_widget('WP_Widget_Media_Audio');
unregister_widget('WP_Widget_Media_Image');
unregister_widget('WP_Widget_Media_Video');
unregister_widget('WP_Widget_Media_Gallery');
unregister_widget('WP_Widget_Meta');
unregister_widget('WP_Widget_Search');
unregister_widget('WP_Widget_Text');
unregister_widget('WP_Widget_Categories');
unregister_widget('WP_Widget_Recent_Posts');
unregister_widget('WP_Widget_Recent_Comments');
unregister_widget('WP_Widget_RSS');
unregister_widget('WP_Widget_Tag_Cloud');
unregister_widget('WP_Nav_Menu_Widget');
unregister_widget('WP_Widget_Custom_HTML');
}
add_action( 'widgets_init', 'remove_default_widgets' );

Here’s a tip: If you are designing a custom theme, it is better to unregister all the widgets — and then just put a double slash in front of the name of the widgets that you want registered. This practice will allow you to reuse these bits of code in your future website projects.