1
我正在使用高级自定义字段为我的网站生成滑块。每个图像(附件)都有一个自定义字段,使用“页面链接”选项连接到它们,这使我可以将链接与每个图像相关联。下面的代码通过链路拉动,但它是对每个图像是相同的,而不管其中的一个(每个图像应该有不同的链路)显示在滑块WP ACF获取附件“页面链接”URL上的滑块图像数量
<section class="slideshow">
<?php
$images = get_field('slideshow');
if($images):
?>
<?php foreach($images as $image): ?>
<figure>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<figcaption>
<h2><?php echo $image['caption']; ?></h2>
<h4><a href="<?php the_field('url_link'); ?>">View Case Study</a></h4>
</figcaption>
</figure>
<?php endforeach; ?>
<?php endif; ?>
</section>
我还试图使URL_LINK字段特定于下面的图像,但这不会提取任何信息。
<h4><a href="<?php echo $image['url_link']; ?>">View Case Study</a></h4>
非常感谢提前。
您在“幻灯片显示”字段中使用哪种字段类型? –
@JordiNebot - 我正在使用gallery字段类型。 –