Widget queries even when there are no sidebars?

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.

Read More

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

remove_action(‘widgets_init’) doesn’t do anything.

Related posts

Leave a Reply

2 comments

  1. 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);
    
  2. 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);