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 am wanting to see the actual SQL that worpress is running to build certain pages, is there a debug method or some other way to outpout this or view it?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

You can use any one of these filters from /wp-includes/query.php

posts_where_request
posts_groupby_request
posts_join_request
posts_orderby_request
posts_distinct_request
posts_fields_request
post_limits_request

You can print certain parts of the query to the screen to see what's going on under the hood.

For instance, you can add this to your functions file:

add_filter('posts_where_request', 'foo_bar', 1, 10);
function foo_bar($where){
    print_r($where);
    return $where;
}
share|improve this answer
    
I also just found this debug file wordpress.stackexchange.com/questions/1567/… it shows all the queries ran, there sql and time to run and methods called –  jasondavis Oct 5 '11 at 2:37
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.