WP_Query::is_main_query()publicWP 3.3.0

Determines whether the query is the main query.

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.

WP_Query::is_main_query() code WP 6.4.3

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