简体   繁体   English

ACF转发器字段看不到行

[英]ACF Repeater field not seeing rows

Have a repeater field that looks to see what the section type is and then outputs certain code base on that type. 有一个repeater字段,它看起来是什么节类型,然后根据该类型输出某些代码。 For some reason the code is always outputting "No Rows Found" even though there are rows. 由于某些原因,即使有行,代码也总是输出“ No Rows Found”。

I have this working already for something else but wanting to use it again to output something different its not working. 我已经在其他方面工作了,但是想再次使用它来输出其他无法正常工作的内容。

Here is the code below 这是下面的代码

<?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;
?>

Here is the config on ACF side 这是ACF端的配置

http://i.stack.imgur.com/SbHDp.png http://i.stack.imgur.com/7zvP3.png http://i.stack.imgur.com/SbHDp.png http://i.stack.imgur.com/7zvP3.png

Your code looks different to the sample code on the ACF website: 您的代码看起来与ACF网站上的示例代码不同:

http://www.advancedcustomfields.com/resources/repeater/ http://www.advancedcustomfields.com/resources/repeater/

Try swapping out your while for the following: 尝试将您的while换成以下内容:

while ( have_rows('layout_section') ) : the_row();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM