Home > OS >  How to get two href with a condition in a button with php?
How to get two href with a condition in a button with php?

Time:01-24

On my page, I have a button that links to a form. Right now, it s linked to the English version even when the page is in Spanish. Is it possible to add a condition like, if the English version => link to the English version form and if it s the Spanish version link to the Spanish form? On this button <a href="/apply/" ><?php _e("Let's Grow", "mywebsite"); ?></a> The spanish link is /aplicar/

Thank you in advance!

<div >
   <div >
     <div >
    <div ></div>
       <div >
         <h3><?php _e("we believe your potential", "mywebsite"); ?><br/><?php _e("is good business", "mywebsite"); ?>.</h3>
        <a href="/apply/" ><?php _e("Let's Grow", "mywebsite"); ?></a>
          </div>
        </div>
        </div>
          </div>

CodePudding user response:

you can use get_locale():

<?php $link = get_locale() == 'es_ES' ? 'aplicar' : 'apply'; ?>
<a href="<?php echo esc_url( home_url('/'. $link ) ); ?>" ><?php _e("Let's Grow", "ascendus"); ?></a>
  • Related