WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've found that is_front_page appears to return true when I'm viewing the home page and have a single sticky post assigned there.

It also returns true when I've assigned a page as the static front page via Settings > Reading.

Why would I ever want to use is_home()?

share|improve this question
up vote 28 down vote accepted

is_front_page() returns true if the user is on the page or page of posts that is set to the front page on Settings->Reading->Front page displays

So if you set about us as the front page then this conditional will only be true if showing the about us page.

is_home() return true when on the posts list page, This is usually the page that shows the latest 10 posts.

If the settings under Front page displays are left at default then the home page will return true for both is_front_page() and is_home()

An example of using is_home():

  • You have set your posts page to a page called News.
  • A user navigates there and in the header you want to show additional navigation
  • You could use is_home() to do this.
share|improve this answer
12  
Exactly. I differentiate as follows: is_front_page() returns true when viewing the Site Front Page (whether displaying the blog posts index or a static page), while is_home() returns true when viewing the Blog Posts Index (whether displayed on the front page or on a static page). – Chip Bennett Oct 6 '11 at 11:40

You'd want to use is_home() when you want to check if the user is viewing your list of blog posts (usually set to display 10 posts per page). If you have a home.php file in your theme, that will be displayed when the is_home() condition is true.

The following can possibly remove some confusion as well: when is_front_page() and is_home() conditions, both are true, the template front-page.php will be used instead of home.php.

share|improve this answer

I've discovered that is_home() and is_front_page() don't deliver what's expected for multisites. My workaround using built in PHP goodies:

if($_SERVER['REQUEST_URI'] == '/') {
    // you must be on the home page
}
share|improve this answer
    
Please elaborate on how it doesn't deliver what's expected. – Christine Cooper May 3 at 16:58
    
On a multi-site main site if you use any form of is_home() or is_front_page() on a static or blog frontpage the functions will both return false. – Dylan Pierce May 3 at 17:12
    
I just tested both conditions on a multisite environment and both returned true when I visited the respective / pages. – Christine Cooper May 4 at 9:53
    
I am using the wordpress VVV box with the multisite plugin : github.com/Varying-Vagrant-Vagrants/vvv-multisite perhaps there's something misconfigured on it? Regardless just leaving an answer for a workaround if anyone comes along with a similar situation. – Dylan Pierce May 4 at 13:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.