WordPress includes many default widgets in the admin area, but some may not fit your theme or simply go unused. To keep the interface clean, you can disable these default widgets using code.
Below is a complete code example showing how to unregister (hide) all default widgets via your theme's functions.php file.
add_action('widgets_init', 'my_unregister_widgets');
function my_unregister_widgets() {
// Unregister core widgets
unregister_widget('WP_Widget_Archives');
unregister_widget('WP_Widget_Calendar');
unregister_widget('WP_Widget_Categories');
unregister_widget('WP_Widget_Links');
unregister_widget('WP_Widget_Meta');
unregister_widget('WP_Widget_Pages');
unregister_widget('WP_Widget_Recent_Comments');
unregister_widget('WP_Widget_Recent_Posts');
unregister_widget('WP_Widget_RSS');
unregister_widget('WP_Widget_Search');
unregister_widget('WP_Widget_Tag_Cloud');
unregister_widget('WP_Widget_Text');
unregister_widget('WP_Nav_Menu_Widget');
// Unregister media widgets (WordPress 5.8+)
unregister_widget('WP_Widget_Media_Image');
unregister_widget('WP_Widget_Media_Gallery');
unregister_widget('WP_Widget_Media_Video');
unregister_widget('WP_Widget_Media_Audio');
}
How to Use
Add the code above to the end of your active WordPress theme's functions.php file. After saving, refresh the Widgets admin page; the unregistered widgets will no longer appear.
Important Notes
- Selective Disabling: You can remove only the
unregister_widgetlines for widgets you wish to keep. For example, to keep only the Search and Categories widgets, delete or comment out the other lines. - Active Widgets: This only affects widget availability in the admin. If a widget is already placed in a sidebar or widget area, it may still appear on the front‑end. You must manually remove it from its widget area.
- Child Theme: It is strongly recommended to make this change in a child theme to prevent your code from being overwritten during theme updates.
Code Explanation
add_action('widgets_init', 'my_unregister_widgets');– This WordPress hook ensures our custom functionmy_unregister_widgetsruns when WordPress initializes the widget system.unregister_widget()– The core WordPress function that removes a registered widget. The parameter is the widget's class name.
Using this method, you can easily clean up the WordPress admin widget list to match your actual needs.