• Resolved multiplier

    (@multiplier)


    In page.php, I need a conditional that says, “If it’s the About page, display this text, if it’s the Contact page display this text, and for all other pages, display this text”.

    I’ve seen examples of multiple conditionals on the Codex page, but they all use an echo. I have PHP functions within my text that won’t execute within the echo. Can anyone demonstrate how to make this work?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Here is the format I use (you can use php between these):

    <?php if (is_page('about') ) { ?>
    <p>About text</p>
    <?php } elseif (is_page('contact') ) { ?>
    <p>Contact text</p>
    <?php } else { ?>
    <p>Default text</p>
    <?php } ?>
    Thread Starter multiplier

    (@multiplier)

    Brilliant, thank you! It was the curly brace before the elseif I had neglected.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple conditionals without using echo?’ is closed to new replies.