How to know which one is the main query?
WP_Query->is_main_query() method source (which function of same name calls) is very short and simple: function is_main_query() { global $wp_the_query; return $wp_the_query === $this; } The main query is the query that is stored in $wp_the_query global. But what is that global? When WP sets up main query it stores it in two places: $wp_the_query and … Read more