How to display all database queries made by Wordpress?

前端 未结 4 1873
生来不讨喜
生来不讨喜 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:00

    or you can hook into posts_request. You can put the coe inside functions.php such as

    add_filter('posts_request','debug_post_request'); // debugging sql query of a post
    
    function debug_post_request($sql_text) {
    
       $GLOBALS['debugku'] = $sql_text; //intercept and store the sql
    return $sql_text; }

    in your theme footer, you can use print_r like

    print_r($GLOBALS['debugku']);
    

提交回复
热议问题