我正在使用以下代码显示图像(位于 ACF 的转发器字段中):
<?php $query = new WP_Query( 'post_type=artworks_post&posts_per_page=-1&order=DESC' ); ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<?php $slides = get_field('project_slider');// Grabs the array
// Check if there is any data in the array before looping
if($slides) {
echo '<div id="slideshow">';
echo '<ul id="slides">';
foreach($slides as $s) {
echo '<li>';
echo '<img src="'.$s['project_image'].'" alt="" height="480" />';
echo '<span>'.$s['project_title'].'</span>';
echo '<span class="project_description">'.$s['project_description'].'</span>';
echo '</li>';
}
echo '</ul>';
}
?>
<?php endwhile; // end of the loop. ?>
问题是它显示了所有自定义帖子(artworks_post)的转发器字段的图像,而不是我在页面中查看的图像。如何将其限制为仅显示已打开帖子的图像?