Forums

If conditions (4 posts)

  1. ohenecoker
    Member
    Posted 2 years ago #

    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

  2. ohenecoker
    Member
    Posted 2 years ago #

    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 } ?>
  3. Simon Prosser
    Theme Review Admin
    Posted 2 years ago #

    <?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 '

  4. ohenecoker
    Member
    Posted 2 years ago #

    Awesome!!! You're a rock star!

    It worked. Thanks a lot Simon

Topic Closed

This topic has been closed to new replies.

About this Topic