0

我在页面上的这个 href 包含在循环 2 滑块中,因此在图像下有一个标题。但是它在单击并打开一个新选项卡时不起作用,它仅在您右键单击然后单击“转到....”时才起作用。有谁知道为什么?

wordpress 上的插件:http: //www.advancedcustomfields.com/

代码: <a class="alt-caption" href="http://<?php the_field('url_site'); ?>"><?php the_field('url_site'); ?></a>

      <div class="paginawrap no_overflow">
        <div class="wraptest">
          <div class="cycle-slideshow" 
               data-cycle-fx="carousel" 
               data-cycle-speed="500" 
               data-cycle-delay=5000
               data-cycle-next=" > img"
               data-cycle-caption=".alt-caption"
               data-cycle-caption-template="{{alt}}"
               data-cycle-carousel-fluid=true
               data-allow-wrap=false
          >
<?php $args = array(
        'post_type' => 'project',
        'posts_per_page' => 10
      );
        $query = new WP_Query( $args );
        if ( $query->have_posts()) :
        while ( $query->have_posts()) :  $query->the_post();
          the_post_thumbnail('home');
        endwhile; wp_reset_postdata();
        endif; ?>

         <a href=" http://<?php the_field('url_site'); ?> "> <div class="alt-caption"></div></a>
          </div>
          <div class="archief1">

          </div>
        </div>
      </div>
4

2 回答 2

1

你的href是空的。让我们看一下您的源代码:

<a class="alt-caption external" href="http://">www.aimassociates.nl</a>

href 属性正在查看“http://”。

也许您必须添加回声?

<?php echo the_field('url_site'); ?>

奇怪的是,相同的 PHP 代码返回不同的结果,您是否像在文件中一样复制/粘贴代码?

你为什么不试试这个?

<?php $site_url = the_field('url_site'); ?>
<a class="alt-caption" href="http://<?php echo $site_url; ?>"><?php echo $site_url; ?></a>
于 2014-01-28T10:15:32.837 回答
0

You use php to load the link. Why not use php the entire way for that line of code? Something like this:

echo('<a class="alt-caption" href="' . $the_field . '" target="_blank"><' . $the_field . '></a>');

Also make sure that your homepage correctly reads the php data.

于 2014-01-28T10:17:37.837 回答