This page redirects to an external site: https://developer.wordpress.org/reference/functions/is_home/
Languages: English • 中文(简体) • עברית • 日本語 Türkçe • (Add your language)
This Conditional Tag checks if the blog posts index page is being displayed. This is a Boolean function, meaning it returns either TRUE or FALSE.
<code style="color: #000000"><span style="color: #0000BB"><?php is_home</span><span style="color: #007700">(); </span><span style="color: #0000BB">?></span></code>
This tag does not accept any parameters.
Since WordPress 2.1, when the static front page functionality was introduced, the blog posts index and site front page have been treated as two different query contexts, with is_home() applying to the blog posts index, and is_front_page() applying to the site front page.
Be careful not to confuse the two query conditionals:
is_front_page() will always return TRUE, regardless of whether the site front page displays the blog posts index or a static page.is_home() will always return TRUE, regardless of whether the blog posts index is displayed on the site front page or a separate page.Whether is_home() or is_front_page() return TRUE or FALSE depends on the values of certain option values:
get_option( 'show_on_front' ): returns either 'posts' or 'page'get_option( 'page_on_front' ): returns the ID of the static page assigned to the front pageget_option( 'page_for_posts' ): returns the ID of the static page assigned to the blog posts index (posts page)When using these query conditionals:
'posts' == get_option( 'show_on_front' ):
is_front_page() will return TRUEis_home() will return TRUE'page' == get_option( 'show_on_front' ):
is_front_page() will return TRUEis_home() will return FALSEis_front_page() will return FALSEis_home() will return TRUEThe following example can be used in your sidebar to display different content when displaying the blog posts index.
<code style="color: #000000">
<span style="color: #0000BB"><?php
</span><span style="color: #007700">if ( </span><span style="color: #0000BB">is_home</span><span style="color: #007700">() ) {
</span><span style="color: #FF8000">// This is the blog posts index
</span><span style="color: #0000BB">get_sidebar</span><span style="color: #007700">( </span><span style="color: #DD0000">'blog' </span><span style="color: #007700">);
} else {
</span><span style="color: #FF8000">// This is not the blog posts index
</span><span style="color: #0000BB">get_sidebar</span><span style="color: #007700">();
}
</span><span style="color: #0000BB">?>
</span></code>
is_home uses the global $wp_query WP_Query object. is_home isn't usable before the parse_query action.
Prior to WordPress 2.1, WordPress did not have static front page functionality, which meant that the site front page and the blog posts index were always the same. Thus, is_home() always returned TRUE on the site front page.
Since: 1.5.0
is_home() is located in wp-includes/query.php.