【问题标题】:How can I target variable in href in php?如何在 php 中定位 href 中的变量?
【发布时间】:2023-01-09 13:39:10
【问题描述】:

所以问题是我有 2 个文件。其中一个 url 被重定向到 php 的一个变量并且它的 orking 很好,代码是 -

 function listdo_listing_website($post) {             
   global $post;                                                                
   $website = get_post_meta( get_the_ID(), '_job_website', true);
   if(!empty($website)):                                                      
      echo '<div class="listing-review-btn"><a class="listing-website" href="'.esc_url( $website ).'"><i class="flaticon-unlink"></i><span class="text"> '.esc_html__('Book Now', 'listdo').'</span></a></div>';                                           
   endif;`

但我试图在另一个文件中执行此操作,但代码无法正常工作 代码 -

<h3 class="listing-title">                   
                <a class="listing-website" href="'.esc_url( $website ).'"><?php the_title(); ?></a> 
                <?php do_action( 'listdo-listings-logo-after', $post ); ?>
</h3>`

这有什么问题?

我试图在 href 中重定向一个 PHP 变量,但它不起作用

【问题讨论】:

    标签: php wordpress variables href


    【解决方案1】:

    您错过了 URL 上的回显

    <h3 class="listing-title">
      <a class="listing-website" href="<?php echo esc_url( $website ); ?>"><?php the_title(); ?></a>   <?php do_action( 'listdo-listings-logo-after', $post ); ?>
    </h3>
    

    【讨论】:

      猜你喜欢
      • 2012-01-05
      • 2015-07-28
      • 1970-01-01
      • 2014-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-27
      • 2018-11-10
      相关资源
      最近更新 更多