WP_Query::is_main_query
Determines whether the query is the main query.
Method of the class: WP_Query{}
No Hooks.
Returns
bool. Whether the query is the main query.
Usage
global $wp_query; $wp_query->is_main_query();
Notes
Global. WP_Query. $wp_the_query WordPress Query object. |
Changelog
| Since 3.3.0 | Introduced. |
WP_Query::is_main_query() WP Query::is main query code WP 7.1
public function is_main_query() {
global $wp_the_query;
return $wp_the_query === $this;
}