Support » Themes and Templates » elseif is_page is not working

  • 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 } ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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 } ?>

    thank you! that’s working most splendidly!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘elseif is_page is not working’ is closed to new replies.