In WordPress, is_home() returns true on the blog posts index, the page that lists your latest posts. This can be the front page or a separate Posts page.
The name is confusing. It does not mean "the home page". For the site front page, use is_front_page().
Syntax
Use it as the test of an if statement.
WordPress
if ( is_home() ) {
// code for the true path
} else {
// code for the false path
}
Call
What it does
is_home()
True on the blog posts index.
is_front_page()
True on the site front page.
is_home() && ! is_front_page()
True on a separate Posts page.
The theme file for this page is home.php (or index.php if there is no home.php).
Full declaration
WordPress
is_home(): bool
Parameters
Parameter
Description
None
This function takes no parameters.
Return Value
Return Value
Description
bool
true if the main query is the blog posts index, otherwise false.
WordPress Examples
Three short theme examples. Each one shows what prints on the true path and the false path.
Example 1 — Blog page heading
Print a heading only on the blog index.
WordPress
<?php if ( is_home() ) {
echo '<h1>Latest from the blog</h1>';
} ?>
Output
On the blog index (true):
<h1>Latest from the blog</h1>
On a single post (false):
(nothing is printed)
How It Works
is_home() is true on the page that lists posts.
The heading is printed only there.
Single posts and pages skip it.
Example 2 — Separate Posts page
Detect the Posts page when a static front page is used.
WordPress
<?php if ( is_home() && ! is_front_page() ) {
echo 'This is the Posts page.';
} ?>
Output
Static front page + Posts page at /blog/ (true):
This is the Posts page.
On the front page / (false):
(nothing is printed)
How It Works
is_home() is true on the Posts page.
! is_front_page() removes the case where the home URL lists posts.
On the blog index (true):
(widgets of blog-sidebar)
On other pages (false):
(widgets of sidebar-1)
How It Works
The if runs on the blog index.
Other pages use the normal sidebar.
Both calls print widgets for the sidebar you name.
Frequently Asked Questions
It returns true or false (a bool). Use it inside an if statement.
No. It is the blog posts index. Use is_front_page() for the site front page.
No. On a static front page, is_home() is false. It is true only on the page set as Posts page.
WordPress uses home.php, then index.php. With a static front page it uses front-page.php for the home URL.
Conditional tags need the main query. Call them in template files or on hooks such as wp or template_redirect, not directly at the top of functions.php.