Wordpress Snippets

Remove Default WordPress Widgets From Dashboard

WordPress comes with a number of in-built widgets which allow you to easily add additional functionality to your WordPress theme. You can use WordPress Widgets to add content and features to your sidebars or to any other predefined widget locations. But nobody uses all the default widgets. In fact, there are probably a few default widgets that you would never use. As such, it can be helpful to remove default WordPress widgets that you don’t have any plans to use in near future.

WordPress provides us with a function, unregister_widget, that allows us to unregister previously registered widgets. We target the widgets_init hook, the hook that fires directly after all the core widgets have been initialized and registered, to make sure that we can safely remove default WordPress widgets.

To remove these widgets just use the following code snippet. Paste this snippet in your functions.php file to disable all default WordPress widgets. Be sure to remove the lines of the widgets that you want to keep.

// remove default wordpress widgets
function wcs_remove_default_widgets() {
    unregister_widget( 'WP_Widget_Pages' );
    unregister_widget( 'WP_Widget_Calendar' );
    unregister_widget( 'WP_Widget_Archives' );
    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' );
}
add_action( 'widgets_init', 'wcs_remove_default_widgets', 11 );

Hire Us. Or just say Hi!
Need a job? Apply to get one.