1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

WP 2.5 is_home() not working?

Discussion in 'HTML & Website Design' started by Nystul, May 4, 2008.

  1. #1
    I did this:

    <?php if (is_home()) { ?>
    <p>homepage</p>
    <?php } ?>
    SEMrush
    and it isnt working.

    I didnt have my frontpage set as static, so it just shows www. myhomepage. com , so what could be the problem with ?

    Oh yah, it is with a template that I am modifying that I came to have this problem. Can someone provide me with insights on what could have gone wrong ?

    the other conditional tags - is_single etc etc are all working fine.

    Thanks!
     
    Nystul, May 4, 2008 IP
    SEMrush
  2. Nystul

    Nystul Well-Known Member

    Messages:
    3,077
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    175
    #2
    ** Sorry, i managed to find the answer somewhere else **

    For those who interested (anyway) ,

    Add this before your conditional tag -

    <?php wp_reset_query(); ?>

    Because of earlier query is stored, so you want to reset it away, and thus will show the home() condition as true.
     
    Nystul, May 5, 2008 IP
    tbtb likes this.
  3. thomashoi

    thomashoi Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    Hey,

    I'm not a programmer but your post has helped me.

    Thanks for this great tip.
     
    thomashoi, Mar 17, 2011 IP
  4. tbtb

    tbtb Well-Known Member

    Messages:
    3,700
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    165
    #4
    Thanks for the <?php wp_reset_query(); ?> tip ! it helped me solving the problem I had :D

    - Tom
     
    tbtb, Dec 10, 2011 IP