WP_Query::is_front_page() WordPress Method

The WP_Query::is_front_page() method is a boolean function that returns true when the main front page of the site is being displayed. This is the front page that is set in the "Settings > Reading" section of the WordPress admin.

WP_Query::is_front_page() #

Is the query for the front page of the site?


Description

This is for what is displayed at your site’s main URL.

Depends on the site’s "Front page displays" Reading Settings ‘show_on_front’ and ‘page_on_front’.

If you set a static page for the front page of your site, this function will return true when viewing that page.

Otherwise the same as @see WP_Query::is_home()


Top ↑

Return

(bool) Whether the query is for the front page of the site.


Top ↑

Source

File: wp-includes/class-wp-query.php

	public function is_front_page() {
		// Most likely case.
		if ( 'posts' === get_option( 'show_on_front' ) && $this->is_home() ) {
			return true;
		} elseif ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' )
			&& $this->is_page( get_option( 'page_on_front' ) )
		) {
			return true;
		} else {
			return false;
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More