WordPress is_front_page() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Conditional tag

Definition

In WordPress, is_front_page() returns true on the front page of the site, the page people see at your main address, such as https://example.com/.

The front page can be your latest posts or a static page that you chose in Settings > Reading. is_front_page() is true in both cases.

Syntax

Use it as the test of an if statement.

WordPress
if ( is_front_page() ) {
  // code for the true path
} else {
  // code for the false path
}
CallWhat it does
is_front_page()True on the site front page.
is_home()True on the blog posts index (a different thing).
is_front_page() && is_home()True when the front page shows the latest posts.

Do not mix this up with is_home(). See the table below.

Full declaration
WordPress
is_front_page(): bool

Parameters

ParameterDescription
NoneThis function takes no parameters.

Return Value

Return ValueDescription
booltrue if the visitor is on the front page, otherwise false.

Quick comparison:

Reading settingis_front_page()is_home()
Your latest poststrue on the home URLtrue on the home URL
Static page as front pagetrue on that pagefalse on that page
Posts page (blog)falsetrue on the blog URL

WordPress Examples

Three short theme examples. Each one shows what prints on the true path and the false path.

Example 1 — Show a welcome box

Print a message only on the front page.

WordPress
<?php if ( is_front_page() ) : ?>
  <div class="welcome">Welcome to our website!</div>
<?php endif; ?>

How It Works

  1. is_front_page() is true on the main page of the site.
  2. The div is printed only there.
  3. It works for both a static page and latest posts.

Example 2 — Front page with latest posts

Tell the two setups apart.

WordPress
<?php
if ( is_front_page() && is_home() ) {
  echo 'Front page shows latest posts';
} elseif ( is_front_page() ) {
  echo 'Front page is a static page';
} elseif ( is_home() ) {
  echo 'This is the blog posts page';
} ?>

How It Works

  1. Both tags are true when the front page lists latest posts.
  2. Only is_front_page() is true on a static front page.
  3. Only is_home() is true on the separate Posts page.

Example 3 — Hero only on the front page

Load a big banner image on the home page only.

WordPress
<?php if ( is_front_page() ) {
  get_template_part( 'template-parts/hero' );
} ?>

How It Works

  1. get_template_part() loads a small piece of the theme.
  2. It runs only when the visitor is on the front page.
  3. Other pages stay lighter.

Frequently Asked Questions

It returns true or false (a bool). Use it inside an if statement.
is_front_page() is the site front page. is_home() is the blog posts index. They can be the same page or two different pages.
You may have set a static front page. Then the home page is a page, so use is_front_page().
Go to Settings > Reading and choose Your latest posts or A static page.
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.

Next: is_home()

Check if the visitor is on the blog posts index.

is_home() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful