Deactivate WordPress Default Widgets
September 2nd, 2009 by Frank • WordPress Themes • 2 Comments
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.
Info
- Published in WordPress Themes
- Tags: Code, development, PHP, Widget, WordPress, WordPress Hacks
- Comment feed | Trackback URL
- read: 5407 | today: 5
- leave a Comment



Will this load sidebar faster ?
Or you just want to disable the unuseful widget for users ?
@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.