WordPress: The Difference Between is_home and is_front_page

Categories

Tips, Web Design, WordPress

When making WordPress themes there’s 2 functions that are really handy. is_home and 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.

How was it for you? Let me know on BlueSky or Mastodon

(Please) Link to this page

Thanks for reading. I'd really appreciate it if you'd link to this page if you mention it in your newsletter or on your blog.

Related Posts

27 Oct 2013

WordPress Numeric Pagination

I’ve made quite a few WordPress themes in my time, and so I thought I would write a few blog posts sharing some of the code snippets that I find myself using repeatedly.First off is some numeric pagination using native...
17 Oct 2012

WordPress Social Network Aggregation

I really like the idea of a Tumblog – and even have one on Tumblr.com – but I don’t promote it anywhere. Conceptually it’s great – but I don’t like not having control over my content.What I would really like...
26 Aug 2016

My WordPress Wishlist

WordPress 4.6 has recently been released, and now plans are being made for WordPress 4.7. At the start of each new version the WordPress team ask for ideas and suggestions for areas people would like them to focus on. This...
26 Sep 2018

WordPress get_post_gallery() Gutenberg Polyfill

I’m working on a new WordPress theme designed for Gutenberg, however Gutenberg isn’t finished, and there are elements that won’t work until the plugin is merged with core.One such issue, that I ran into this weekend, is that get_post_gallery() doesn’t...
31 Oct 2013

WordPress – Estimated Reading Time

I have a theme coming out soon that displays the ‘estimated reading time’ for each blog post on the homepage.The theme is inspired by the new blogging service Medium – but I first saw the idea mentioned on Brian Crays...
01 Dec 2013

WordPress Improved Human Time Difference

WordPress has a built in function, called human_time_diff, for creating messages that say how long ago a post was published – however I think it is confusing when you have posts from a long time ago that read “posted 15...