ACF Repeater字段没有看到行

时间:2015-01-30 22:51:14

标签: php wordpress advanced-custom-fields

拥有一个转发器字段,该字段可以查看该类型的内容,然后根据该类型输出某些代码。出于某种原因,即使有行,代码也始终输出“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

1 个答案:

答案 0 :(得分:0)

您的代码与ACF网站上的示例代码不同:

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

尝试将while换成以下内容:

while ( have_rows('layout_section') ) : the_row();
相关问题