is_main_query()

最后更新于:2021-11-27 08:57:05

is_main_query()

Determines whether the query is the main query.

响应

(bool) Whether the query is the main query.

源文件

文件: gc-includes/query.php

function is_main_query() {
	global $gc_query;

	if ( 'pre_get_posts' === current_filter() ) {
		_doing_it_wrong(
			__FUNCTION__,
			sprintf(
				/* translators: 1: pre_get_posts, 2: GC_Query->is_main_query(), 3: is_main_query(), 4: Documentation URL. */
				__( 'In %1$s, use the %2$s method, not the %3$s function. See %4$s.' ),
				'<code>pre_get_posts</code>',
				'<code>GC_Query->is_main_query()</code>',
				'<code>is_main_query()</code>',
				__( 'https://docs.gechiui.com/functions/is_main_query/' )
			),
			'3.7.0'
		);
	}

	return $gc_query->is_main_query();
}