Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to reduce my database queries. I don't have any sidebars or widgets set but I noticed the following query

SELECT option_value FROM wp_options WHERE option_name = 'widget_pages' LIMIT 1

Similar queries happen for widget_calendar, widget_links, widget_tag_cloud, and widget_nav_menu.

5 database queries for no reason. How do I disable this?

remove_action('widgets_init') doesn't do anything.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Does unregistering them the also disable the database queries?

Goes in functions.php:

//Unregister all Default 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);
share|improve this answer
    
Yep, this works! –  Rachel Baker Oct 17 '12 at 4:50
add comment

I have the following code in a theme, it stops any related db queries from running.

function unregister_all_default_wp_widgets() {
   // list the default WordPress widgets here
}
add_action('widgets_init', 'unregister_all_default_wp_widgets', 1);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.