• Dear php gurus,

    HELP,
    I’m trying to use an if condition to display different text depending on whether it’s the regular homepage or the spanish version of the homepage
    here’s what I have so far:

    <?php if(is_page(‘spanish-home’)) {?>
    <?php echo”English“;?> <?php } ?> <?php else {?> <?php echo “Español“;?> <?php } ?>

    I get error messages when I run the code. I’m not experienced in php to diagnose the problem.

    I would be eternally grateful if someone helps me out. Thanks

    -Christian

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ohenecoker

    (@ohenecoker)

    sorry here’s the code again

    <?php if(is_page('spanish-home')) {?>
    				 <?php echo"<a href="#"id="spanish" class="threecol">English</a>";?> <?php } ?>
                     <?php else {?> <?php echo "<a href="#"id="spanish" class="threecol">Español</a>";?> <?php } ?>
    <?php
    echo ( is_page( 'spanish-home' ) ) ? '<a href="#"id="spanish" class="threecol">English</a>' : '<a href="#"id="spanish" class="threecol">Español</a>';
    ?>

    The above will work for you.

    Your error was using ” not ‘

    Thread Starter ohenecoker

    (@ohenecoker)

    Awesome!!! You’re a rock star!

    It worked. Thanks a lot Simon

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘If conditions’ is closed to new replies.