WordPress.org

Ready to get started?Download WordPress

Forums

elseif is_page is not working (3 posts)

  1. nearlythere
    Member
    Posted 9 years ago #

    I want to make something in the sidebar appear differently on a specific page than it does from all other pages, but this is not working... can anyone else see the problem with it?

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

    this shows up on every page, not just the front home page. that's OK.

    <?php } elseif (is_page('portfolio') ) { ?>

    this DOES NOT show up on the portfolio page. but i want it to!

    <?php } else { ?>

    this shows up on non-pages

    <?php } ?>

  2. Kafkaesqui

    Posted 9 years ago #

    The logic of your if/else sort of knocks out all Pages before you can test for 'portfolio', so try this:

    <?php if (is_page('portfolio') ) { ?>

    this WILL show up on the portfolio page.

    <?php } elseif ( is_home() || is_page() ) { ?>

    this shows up on every Page (except portfolio), and the home page.

    <?php } else { ?>

    this shows up on non-pages

    <?php } ?>

  3. nearlythere
    Member
    Posted 9 years ago #

    thank you! that's working most splendidly!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.