簡體   English   中英

如何在帶有 php 的按鈕中獲得兩個帶有條件的 href?

[英]How to get two href with a condition in a button with php?

在我的頁面上,我有一個鏈接到表單的按鈕。 現在,即使頁面是西班牙語,它也會鏈接到英語版本。 是否可以添加一個條件,例如,如果英文版 => 鏈接到英文版表格,如果是西班牙文版鏈接到西班牙文表格? 在這個按鈕上<a href="/apply/" class="btn btn-light mt-5 pr-5 pl-5"><?php _e("Let's Grow", "mywebsite"); ?></a> <a href="/apply/" class="btn btn-light mt-5 pr-5 pl-5"><?php _e("Let's Grow", "mywebsite"); ?></a>西班牙鏈接是 /aplicar/

先感謝您!

<div class="banner bg-purple">
   <div class="container">
     <div class="row d-flex align-items-center m-h-400 bg-img-building-blocks">
    <div class="col-6"></div>
       <div class="col-6">
         <h3><?php _e("we believe your potential", "mywebsite"); ?><br/><?php _e("is good business", "mywebsite"); ?>.</h3>
        <a href="/apply/" class="btn btn-light mt-5 pr-5 pl-5"><?php _e("Let's Grow", "mywebsite"); ?></a>
          </div>
        </div>
        </div>
          </div>

你可以使用get_locale()

<?php $link = get_locale() == 'es_ES' ? 'aplicar' : 'apply'; ?>
<a href="<?php echo esc_url( home_url('/'. $link ) ); ?>" class="btn btn-light mt-5 pr-5 pl-5"><?php _e("Let's Grow", "ascendus"); ?></a>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM