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.
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.
is_hometells you if you are on the blog post list page. This is the default WordPress homepage that shows the reverse chronological list of blog posts. It will also be true if you have moved the blog post list to another page when assigning a static home page.
is_front_pagetells 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.
Ben is a lifelong Nintendo fan who also likes to build websites, and develop games. He also buys way too much Lego.