[英]ACF Repeater field not seeing rows
有一个repeater字段,它看起来是什么节类型,然后根据该类型输出某些代码。 由于某些原因,即使有行,代码也总是输出“ No Rows Found”。
我已经在其他方面工作了,但是想再次使用它来输出其他无法正常工作的内容。
这是下面的代码
<?php if( have_rows('layout_section') ): ?>
<?php while(the_repeater_field('layout_section')): ?>
<?php if (get_sub_field('layout_section_type') == "test") { ?>
<?php the_sub_field('post_id'); ?>
<?php } elseif ( get_sub_field('layout_section_type') == "featured" ) { ?>
<p>Featured Section</p>
<?php } elseif ( get_sub_field('layout_section_type') == "test2" ) { ?>
<p>Tewsat 2</p>
<?php } else { ?>
<p>Normal Section</p>
<?php } ?>
<?php endwhile; ?>
<?php
else :
echo 'No Rows Found';
// no rows found
endif;
?>
这是ACF端的配置
http://i.stack.imgur.com/SbHDp.png http://i.stack.imgur.com/7zvP3.png
您的代码看起来与ACF网站上的示例代码不同:
http://www.advancedcustomfields.com/resources/repeater/
尝试将您的while
换成以下内容:
while ( have_rows('layout_section') ) : the_row();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.