Skip to content

Instantly share code, notes, and snippets.

@stephenharris
Created March 24, 2013 16:18
Show Gist options
  • Save stephenharris/5232517 to your computer and use it in GitHub Desktop.
Save stephenharris/5232517 to your computer and use it in GitHub Desktop.
Very simple script for debugging queries
<?php
/**
* Will print to the page the main query used for that page. It will do this only for admins.
* This can be put in your theme's functions.php, but should be removed when its no longer needed.
*/
add_action( 'posts_request', 'debug_post_request', 10, 2 );
function debug_post_request( $r, $query ){
if( current_user_can( 'manage_options' ) && $query->is_main_query() ){
echo '<pre>';
print_r( $query );
echo '</pre>';
}
return $r;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment