[英]Wordpress ACF repeater field loop
我试图在我的wordpress主页模板中循环出一个Repeater字段,但是由于某些原因,该div为空并且似乎无法正常工作。 我100%确定自己的代码正确无误,所以一定有问题。 任何人都知道可能是什么吗?
这是我的循环的样子,字段键正确! :)
<?php
/**
* Template Name: Front Page Template
*/
?>
<?php while(have_posts()) : the_post(); ?>
<?php if( have_rows('achtergrond_afbeeldingen') ): ?>
<div class="slider-circles">
<?php while ( have_rows('achtergrond_afbeeldingen') ) : the_row(); ?>
<p id="slide1" data-bgimage="<?php the_sub_field('image'); ?>" class="transparent-circle slick-active"></p>
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php endwhile; ?>
这就是我的front-page.php的样子。 有趣的是,我之前在其他项目中使用过此工具,一切正常。 现在我的屏幕只是空白,我不知道发生了什么。
如果have_rows('field_56e7d8bebb545')确实为true,请调试the_row();
var_dump(the_row());
您可以查看the_result,如果为空,则可能必须为have_row($ field_name, $ post_id )设置第二个参数
尝试这个..,因为您还没有打印出任何可以在浏览器中显示的东西。.您仅向div提供了data属性。
在内部HTML中写一些东西可能会看到您的中继器值
<?php
/**
* Template Name: Front Page Template
*/
?>
<?php while(have_posts()) : the_post(); ?>
<?php if( have_rows('achtergrond_afbeeldingen') ): ?>
<div class="slider-circles">
<?php while ( have_rows('achtergrond_afbeeldingen') ) : the_row(); ?>
<p id="slide1" data-bgimage="<?php the_sub_field('image'); ?>" class="transparent-circle slick-active"><?php the_sub_field('image'); ?></p>
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php endwhile; ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.