Skip to content

Instantly share code, notes, and snippets.

@DrewAPicture
Created November 18, 2012 05:01
Show Gist options
  • Save DrewAPicture/4103650 to your computer and use it in GitHub Desktop.
Save DrewAPicture/4103650 to your computer and use it in GitHub Desktop.
Unregister all Core widgets
/**
* Unregister Core Widgets
*
* Unregisters all core widgets based on their individual
* class names.
*
* @uses unregister_widget() to unregister from the Widget Factory class
*/
function remove_core_widgets() {
unregister_widget( 'WP_Widget_Calendar' );
unregister_widget( 'WP_Widget_Pages' );
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' );
}
add_action( 'widgets_init', 'remove_core_widgets' );
@DrewAPicture
Copy link
Author

On a relatively vanilla site (maybe 3 plugins) unregistering the unneeded core widgets saved 6 queries on the homepage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment