Support » Plugins and Hacks » Conditional content based upon is_page() not echoing as expected

  • Gilad

    (@virtualgilad)


    Greetings!

    I have a block of code that looks like this:

    <?php
    if (is_page()) {
    echo ‘Something for Pages’;
    } else {
    echo ‘Something for Posts’;
    }
    ?>

    Unexpectedly, the ‘Something for Posts’ shows on Pages as well as Posts.

    What am I doing wrong?

    Apologies for the lack of links – These experiments (my first WP sites, really) only exist on my dev box for now…

    TIA!
    Gilad

Viewing 3 replies - 1 through 3 (of 3 total)
  • Gilad, I tested your code on one of my page templates in WP 2.7 and it worked perfectly. The ‘Something for Posts’ did not show up.

    Gilad

    (@virtualgilad)

    Thanks for the quick assist!

    I’m still on 2.6 on this particular site. I wonder if this is only supposed to work in 2.7… Or if there is something else I have breaking me…

    I’ll upgrade to 2.7 tonight and report back to this thread.

    Thanks again!
    Gilad

    Gilad

    (@virtualgilad)

    Well, the upgrade had to be postponed, and then I forgot I owed a response to this thread… Silly me…

    Anyway – Once I upgraded to 2.7, the code behaved as expected.

    Thanks for the hint, cafefrenzy!

    Gilad

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Conditional content based upon is_page() not echoing as expected’ is closed to new replies.