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";

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

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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