[wp-hackers] Seeing the Actual SQL statements WP is running when compiling the posts...
Dion Hulse (dd32)
wordpress at dd32.id.au
Sat Dec 3 04:16:22 UTC 2011
2 step process:
1. Install the Debug Bar plugin
2. define WP_DEBUG and SAVEQUERIES in your wp-config.php file to true.
You can then check out the Queries tab of the Debug bar, and you'll
see all queries made, and by which functions. It won't link your exact
query_posts args to a SQL, but you should be able to work out which
one it is pretty quickly by the function backtraces.
If you're using a WP_Query instance for a loop, you should also be
able to dump out $query->request (I think that's the field) which is
hte SQL for that instance of WP_Query, alternatively, just dump the
entire object to screen, and you'll spot the SQL field.
On 3 December 2011 15:02, IC IC <icwordpress at gmail.com> wrote:
> Is there a way to see/output the actual SQL query wp runs for
> compiling the current page record(s)?
> For learning purposes, I'd like to see what SQL query runs when we say
> query_posts( 'cat=1&tag=apples+apples' );
> or when I am serving a taxonomy page such as
> what's the SQL query WP is running? Can I hook into that section and
> output the SQL statement on the screen?
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers