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

None of the following are working to display conditional format in the sidebar when the current page is the home page:

  • is_front_page,
  • is_page('home'),
  • is_page(id)

I added an else clause which is implemented on the home page.

In Options > Reading, I have specified a page called Home to be the front page. The slug 'home' and the page id of 13 (obtained from the URL when editing the Home page) all return false.

If I place <?php the_ID(); ?> in the sidebar, it displays the post ids of blog posts which are also displayed (title only) by home.php (which is the template assigned to the home page).

I don't know how else to explicitly display the page id on the front end so I know I'm using the correct id.

share|improve this question
up vote 1 down vote accepted

Try putting a wp_reset_query function call after your loop on the homepage template.

If you're using a custom query on the home page and not used wp_reset_query, then the conditional check will always point to the last post fetched by that custom query hence failing to check if homepage.

share|improve this answer
Perfect. Thanks. – Steve Nov 9 '11 at 11:27
Cool... you're welcome! – Rutwick Gangurde Nov 9 '11 at 15:36

Without seeing exactly what's going in your code, it sounds like the spot you are testing the page ID within the sidebar is already within a loop displaying posts on your sidebar.

Try running your conditional test before the sidebar loop begins, possibly storing it in a different variable in your home.php file and checking that variable in the sidebar instead of the current post ID

share|improve this answer

Your Answer


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.