繁体   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