Support » Fixing WordPress » is_home problem

  • Hello,
    strange thing with is_home: if I put only one condition – if(is_home()) – it doesn’t’show; if I put more than one, if ( (is_home()) || (is_archive()) ), for example, it works. Any suggestions?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Care to post some code? As given, there’s no reason for it to behave as you say. Stick something up on http://pastebin.com or something.

    <?php if ( (is_home()) || (is_archive()) ) { ?>
    – works
    <?php } ?>

    <?php if (is_home()) { ?>
    – works only first time
    <?php } ?>

    I know, it’s weird… 🙂
    Perhaps someting in php code in between…
    The code is placed in sidebar.php.

    How do you mean “works only first time”? Do you mean if you refresh the page it doesn’t work? or if you return to the homepage it doesn’t work on the second visit. (Is it a browser cache issue? F5?)

    I’ve just checked this code in my site

    <?php if (is_home()) { ?>

    and it works fine. A block on my sidebar now only appears on the home page.

    What I did discover, however, is that if I had something (X)HTML-commented-out either before or after it, eg

    <?php if (is_home()) { ?>
    <!-- <?php /* If this is the home page */ if ( (is_home()) or (is_page('contact')) ) { ?> -->

    then I’d get an error and in the spirit of Gandalf: None shall pass!

    Gareth

    Thanks,
    The problem was similar, a php comment, something like <?php … { /* ?> in the middle of the page, and after that is_home() didn’t work anymore 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘is_home problem’ is closed to new replies.