How to Remove Default WordPress Widgets and Clean Up Your Widgets Page


Let’s be honest – nobody uses all the default widgets that come with WordPress out of the box. In fact, there are probably a few default widgets that you would never use. Ever.

Because of this, many of those default widgets just get in the way. And so if you’d like to remove them and clean up your widgets page, there’s an easy way.

If you “unregister” a widget in your functions file, it will not appear on your widgets page. If you’d ever like it to appear again, simply go back into your functions file and remove the code you put in to unregister it.

Below is the code to put into your functions file to remove ALL the default widgets that come with WordPress. You can pick and choose which ones you’d like. If you’d like to keep your text widget, for example, then simply remove the line of code for the text widget:

unregister_widget('WP_Widget_Text');

 

Place the following in your functions file (Appearance > Editor > Theme Functions – functions.php):

 

// unregister all widgets
 function unregister_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_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('Twenty_Eleven_Ephemera_Widget');
 }
 add_action('widgets_init', 'unregister_default_widgets', 11);

 

Featured Plugin - WordPress Newsletter Plugin

Now there's no need to pay for a third party service to sign up, manage and send beautiful email newsletters to your subscriber base - this plugin has got the lot.
Find out more

Here’s a look at all the default widgets:

And here’s a look at the default widgets removed:

Featured Plugin - WordPress Pop-Up Chat Plugin

No javascript required, no third part chat engine, just fully featured chat right in your own database on your own WP sites - couldn't be easier.
Find out more

 

 

Photo: Pretty Woman Cleaning from BigStock

 

 

Tags , ,

Comments (8)

  1. Great! I have one question, regarding the line:


    add_action('widgets_init', 'unregister_default_widgets', 11);

    When you’re passing the ’11’ parameter, what does it refers to? I mean, If I remove more or less widgets, will it affect somehow?

    Thanks a lot, really useful stuff ;)

  2. Sorry, but that’s all wrong. All of it. Seriously. You never know which widgets were registered and which weren’t, which are the standard ones and which came with a theme or plugin. Like you’re trying to unregister the Twenty Eleven Ephemera widget, what if the Twenty Eleven theme is not active? What if two more default widgets are added to Core in 3.4? Dude, all you had to do was read the default-widgets.php file to realize you can remove them in one line, and still run widgets_init in another one line ;)

    remove_action( ‘init’, ‘wp_widgets_init’, 1 );
    add_action( ‘init’, function() { do_action( ‘widgets_init’ ); }, 1 );

    Cheers.

Participate