How to display all database queries made by Wordpress?

前端 未结 4 1868
生来不讨喜
生来不讨喜 2020-12-13 05:42

Using a method similar to the one described here, I can see the total number of queries being made in Wordpress when I load a page.

Now I\'d like to display all da

4条回答
  •  [愿得一人]
    2020-12-13 06:11

    If you add define('SAVEQUERIES', true) to your configuration file, you can then list all the queries made for the current page by adding the following to your theme.

    if (current_user_can('administrator')){
        global $wpdb;
        echo "
    ";
        print_r($wpdb->queries);
        echo "
    "; }

    See the documentation for more details: http://codex.wordpress.org/Editing_wp-config.php#Save_queries_for_analysis

提交回复
热议问题