Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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";
       else
       echo "you are not on front page";
share|improve this question

1 Answer 1

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
1  
found it - forgot wp_reset_query() after the second loop –  byronyasgur Jan 5 '12 at 12:15

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.