2

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.

2 Answers 2

3

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);
1
0

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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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