2 回答
TA贡献1712条经验 获得超3个赞
转发器内的字段将称为子字段 ( get_sub_field),因此您的代码应该是
$rows = get_sub_field('slideshow');
if($rows) {
$image = get_sub_field('background_image');
$size = 'full';
foreach($rows as $row) {
?>
<li class="swiper-slide">
<div class="bg parallax2" data-speed='.5' style='background-image: url("<?php echo $image['url']; ?>")'></div>
</li>
<?php
}
}
?>
TA贡献1887条经验 获得超5个赞
这应该有效:
<?php
$homepageFields = get_field('homepage');
$slideshow = $homepageFields['slideshow'];
if ($slideshow) {
$size = 'full';
foreach ($slideshow as $row) {
$image = $row['background_image'];
?>
<li class="swiper-slide">
<div class="bg parallax2" data-speed='.5' style='background-image: url("<?php echo $image['sizes'][$size]; ?>")'></div>
</li>
<?php
}
}
?>
- 2 回答
- 0 关注
- 166 浏览
添加回答
举报