WordPress.org

Ready to get started?Download WordPress

Forums

Conditional content based upon is_page() not echoing as expected (4 posts)

  1. VirtualGilad
    Member
    Posted 5 years ago #

    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

  2. cafefrenzy
    Member
    Posted 5 years ago #

    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.

  3. VirtualGilad
    Member
    Posted 5 years ago #

    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

  4. VirtualGilad
    Member
    Posted 5 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic