if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_home();
* Determines whether the query is for the Privacy Policy page.
* The Privacy Policy page is the page that shows the Privacy Policy content of the site.
* is_privacy_policy() is dependent on the site's "Change your Privacy Policy page" Privacy Settings 'wp_page_for_privacy_policy'.
* This function will return true only on the page you set as the "Privacy Policy page".
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is for the Privacy Policy page.
function is_privacy_policy() {
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_privacy_policy();
* Determines whether the query is for an existing month archive.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is for an existing month archive.
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_month();
* Determines whether the query is for an existing single page.
* If the $page parameter is specified, this function will additionally
* check if the query is for one of the pages specified.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @param int|string|int[]|string[] $page Optional. Page ID, title, slug, or array of such
* to check against. Default empty.
* @return bool Whether the query is for an existing single page.
function is_page( $page = '' ) {
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_page( $page );
* Determines whether the query is for a paged result and not for the first page.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is for a paged result.
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_paged();
* Determines whether the query is for a post or page preview.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is for a post or page preview.
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_preview();
* Is the query for the robots.txt file?
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is for the robots.txt file.
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_robots();
* Is the query for the favicon.ico file?
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is for the favicon.ico file.
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_favicon();
* Determines whether the query is for a search.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is for a search.
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_search();
* Determines whether the query is for an existing single post.
* Works for any post type, except attachments and pages
* If the $post parameter is specified, this function will additionally
* check if the query is for one of the Posts specified.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @param int|string|int[]|string[] $post Optional. Post ID, title, slug, or array of such
* to check against. Default empty.
* @return bool Whether the query is for an existing single post.
function is_single( $post = '' ) {
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_single( $post );
* Determines whether the query is for an existing single post of any post type
* (post, attachment, page, custom post types).
* If the $post_types parameter is specified, this function will additionally
* check if the query is for one of the Posts Types specified.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @param string|string[] $post_types Optional. Post type or array of post types
* to check against. Default empty.
* @return bool Whether the query is for an existing single post
* or any of the given post types.
function is_singular( $post_types = '' ) {
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_singular( $post_types );
* Determines whether the query is for a specific time.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is for a specific time.
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_time();
* Determines whether the query is for a trackback endpoint call.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is for a trackback endpoint call.
function is_trackback() {
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_trackback();
* Determines whether the query is for an existing year archive.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is for an existing year archive.
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_year();
* Determines whether the query has resulted in a 404 (returns no results).
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is a 404 error.
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_404();
* Is the query for an embedded post?
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is for an embedded post.
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return $wp_query->is_embed();
* Determines whether the query is the main query.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @return bool Whether the query is the main query.
function is_main_query() {
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '6.1.0' );
if ( 'pre_get_posts' === current_filter() ) {
/* translators: 1: pre_get_posts, 2: WP_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>WP_Query->is_main_query()</code>',
'<code>is_main_query()</code>',
__( 'https://developer.wordpress.org/reference/functions/is_main_query/' )
return $wp_query->is_main_query();
* The Loop. Post loop control.
* Determines whether current WordPress query has posts to loop over.
* @global WP_Query $wp_query WordPress Query object.
* @return bool True if posts are available, false if end of the loop.
if ( ! isset( $wp_query ) ) {
return $wp_query->have_posts();
* Determines whether the caller is in the Loop.
* For more information on this and similar theme functions, check out
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
* Conditional Tags} article in the Theme Developer Handbook.
* @global WP_Query $wp_query WordPress Query object.
* @return bool True if caller is within loop, false if loop hasn't started or ended.
if ( ! isset( $wp_query ) ) {
return $wp_query->in_the_loop;
* @global WP_Query $wp_query WordPress Query object.
function rewind_posts() {
if ( ! isset( $wp_query ) ) {
$wp_query->rewind_posts();
* Iterate the post index in the loop.
* @global WP_Query $wp_query WordPress Query object.