Deactivate WordPress Default Widgets

You do not always want to have all the widgets active, which comes within the WordPress core.

You can disable the unneccessary Widgets in your functions.php of your theme with a small function. The following syntax will switch off all the standard widgets. It should therefore be adjusted depending on your requirements:

// unregister all default WP Widgets
function unregister_default_wp_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_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');
}

add_action('widgets_init', 'unregister_default_wp_widgets', 1);

The function unregister_widget() needs as parameters the class, therefore the code is working since version 2.8 only. In prior versions, Widgets were supported differently.

How to create your own Widgets since WordPress Version 2.8 is explained in Build A WordPress 2.8 Widget With The New Widget API.

Comments are closed.

5 comments

  1. Mael

    Will this load sidebar faster ?
    Or you just want to disable the unuseful widget for users ?

  2. Frank

    @Mael: no, its not for the performance, is for a customzing in backend for custom. Maybe you write a theme with widgtets, and the custom will only your new widgets for his users in backen - you must deaktive the default widgets.

  3. Hristo

    Does anyone know how can I unregister the Menu Nav Widget?

  4. Michael

    @Hristo: unregister_widget('WP_Nav_Menu_Widget');

  5. Debbie

    This worked amazingly well, thanks.

    The one thing I'm still desperately looking for and can't seem to figure out is how to, within multisite, have some widgets already activated on the sidebars by default for every user activating this theme.

    I would like to have them activated on the sidebars by default without hardcoding them in the theme, because I would like my users to drag them out if they prefer, or move them around on different sidebars.

    It's slightly off topic but I would really appreciate it if someone knew how to do this. I did find someone asking the same thing on the wordpress forums but nobody knew the answer over there.