WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 2 down vote accepted

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


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

Your Answer


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.