WordPress at a glance
function is not described

WP_Query::is_main_query() public WP 3.3.0

Is the query the main query?

{} It's a method of the class: WP_Query{}

No Hooks.

Return

true/false. Whether the query is the main query.

Usage

global $wp_query;
$wp_query->is_main_query();

Notes

  • Global. WP_Query. $wp_query WordPress Query object.

Changelog

Since 3.3.0 Introduced.

Code of WP_Query::is_main_query() WP 5.5.3

<?php
public function is_main_query() {
	global $wp_the_query;
	return $wp_the_query === $this;
}