When making WordPress themes there’s 2 functions that are really handy.
is_front_page. I use them all the time in both themes and plugins. But I can never remember the difference between them.
is_home vs is_front_page
On the surface they are both the same. They tell you if the page you are loading is the front page or not. But there’s more to it than that. So, I thought I would write this so I have something to refer to when I next forget.
What is is_home?
is_home tells you if you are on the blog post list page/ archive page. This is the default WordPress homepage that shows the reverse chronological list of blog posts. However, if you have setup a static front page then the blog post page will move and so it will no longer be true for the actual homepage.
This is confusing because the function is called
is_home but it’s not always the homepage. It’s only the homepage if you have not set a static front page.
What is is_front_page?
is_front_page tells you if you are on the front page of the site, whatever the content being shown. If it’s a static home page, or a list of blog posts, or something else it will be true. Any other page and it will be false.
As you can see
is_home is not always the homepage (front page), it could potentially be anywhere on your site. Hence the constant confusion.