【发布时间】:2015-06-12 08:36:15
【问题描述】:
对于我正在创建的自定义 WP 主题,我正在使用 ACF。我需要一个输出图像的中继器。我将其设置为图像对象并使用正确的代码。事实上,我在没有中继器的情况下尝试过它,它工作得很好。它仅在中继器内失败。
<div class="row col-md-12">
<?php
// check if the repeater field has rows of data
if( have_rows('pics') ):
// loop through the rows of data
while ( have_rows('pics') ) : the_row();
// display a sub field value
?><div class="col-md-4">
<?php
$image = get_field('img');
if( !empty($image) ): ?>
<img src="<?php echo $image; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
</div> <?
endwhile;
else :
// no rows found
endif;
?>
</div>
是什么导致图像数据不循环?
【问题讨论】:
-
也适用于 img 标签“echo $image['url'];”也不能解决问题。
标签: php wordpress plugins repeater advanced-custom-fields