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 want to introduce some code into sidebar.php dependant on whether the site was on the front page or not. ( I have a static front page and am using the front-page.php file ).

To cut a long story short, I have done some testing and I now have the following code in BOTH my front-page.php file and also in the sidebar.php file; but the two bits of code are displaying conflicting results. The same page is telling me both that I am on front page and not on front page at the same time. The reality is that I actually AM on front page so the question i have is this. Is there something wrong with using the tag is_front_page() in sidebar.php ?

if( is_front_page())
       echo "you are on front page";
       echo "you are not on front page";
share|improve this question
up vote 1 down vote accepted

strange thing - try is_home() . what does that returns ?

share|improve this answer
i have sort of figured it out but i am still confused - i moved the position of is_sidebar in the front-page.php file and got a different result - it must have something to do with position relative to the loop or something - i have 2 loops on the page so maybe i've done something wrong with that and confused it – byronyasgur Jan 5 '12 at 12:09
found it - forgot wp_reset_query() after the second loop – byronyasgur Jan 5 '12 at 12:15

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.