簡體   English   中英

ACF轉發器字段看不到行

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM