Ben
Ben is a lifelong Nintendo fan who likes to build websites, and make video games. He buys way too much Lego.
WordPress and Games
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.
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_home
tells 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_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.