Tracing the life of a query

Well you can try and run debug_backtrace(); on your function.

For example:

function wpse_82183_debug( $query ) {
    //your query goes here, this is just a basic one
    if ( $query->is_home() && $query->is_main_query() ) {
         $query->set( 'posts_per_page', 1 );

        //magic happens here
        var_dump(debug_backtrace());
    }
}
add_action( 'pre_get_posts', 'wpse_82183_debug' );

There are also a number of plugins that help figure stuff out,

I recently made this list: http://wycks.github.com/WordPress-Gear/ (click debug tools)

Have a look at :

Leave a Comment