我希望创建一个滑块,使用ACF在每个页面上显示一个单独的滑块,该页面有自己的图像加载到gallery字段中。
目前,我使用flexslider创建了滑块,并成功地获得了要显示的图像,但问题是,所有图像都显示在具有图像集的每个页面上。所以第1页有图像1,这只显示在第1页上(没有其他页面),这就是我想要的。但是,如果将图像添加到第2页,则第1页和第2页都会显示带有图像1和2的滑块。我需要有单独的幻灯片图像为每个单独的页面,我需要滑块不显示,如果没有图像设置在一个页面上。我希望一切都有意义。这是我目前掌握的代码:
<div id="featured" class="flexslider clearfix">
<ul class="slides">
<?php
$args = array(
\'post_type\' => \'page\',
);
$the_query = new WP_Query($args);
?>
<?php if (have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
<?php
$images = get_field(\'slider_image\');
if ($images): ?>
<?php foreach ($images as $image): ?>
<li>
<img src="<?php echo $image[\'url\']; ?>">
</li>
<?php endforeach; ?>
<?php endif; ?>
<?php endwhile; endif;?>
</ul>
</div>
任何帮助都将不胜感激。我猜我需要按id或其他方式循环页面,但我对PHP非常陌生,所以我不完全确定。谢谢