Support

Account

Home Forums Add-ons Repeater Field Repeater field saying no rows found

Solved

Repeater field saying no rows found

  • Have a repeater field that looks to see what the section type is and then outputs certain code base on that type. For some reason the code is always outputting “No Rows Found” even though there are rows.

    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" ) { ?>
    
                Featured Section
    
            <?php } elseif ( get_sub_field('layout_section_type') == "test2" ) { ?>
    
                Tewsat 2
    
            <?php } else { ?>
    
                Normal Section
    
            <?php } ?>
    
        <?php endwhile; ?>
    
    <?php
    else :
        echo 'No Rows Found';
        // no rows found
    endif;
    ?>
  • I think first lines should be:

    <?php if( have_rows('layout_section') ): ?>
    <?php while ( have_rows('layout_section') ) : ?>
    <?php the_row(); ?>

    instead of:

    <?php if( have_rows('layout_section') ): ?>
     <?php while(the_repeater_field('layout_section')): ?>
  • Tried that way and still no luck. It is still saying there are no rows found when there are rows.

    <?php if( have_rows('layout_section') ): ?>
    
        <?php while ( have_rows('layout_section') ) : ?>
    
            <?php the_row(); ?>
    
            <?php if (get_sub_field('layout_section_type') == "feat_section") { ?>
    
                <p>Featured Section</p>
    
            <?php } elseif ( get_sub_field('layout_section_type') == "feat2" ) { ?>
    
                <p>Featured Section 2</p>
    
            <?php } elseif ( get_sub_field('layout_section_type') == "feat3" ) { ?>
    
                <p>Featured Section 3</p>
    
            <?php } else { ?>
    
                <p>Normal Section</p>
    
            <?php } ?>
    
        <?php endwhile; ?>
    
    <?php
    else :
        echo '<p>No Rows Found</p>';
        // no rows found
    endif;
    ?>

    Here are the config pages. First one of the repeater field itself

    The layout type options

    Just using it for text at the moment for debugging

  • Hm, the code looks ok, maybe you can try just this code and check if it returns anything.

    <?php
    if( have_rows('layout_section') ):
        while ( have_rows('layout_section') ) : the_row();
            the_sub_field('ENTER HERE SOME FIELD NAME WHERE YOU HAVE SOME TEXT');
        endwhile;
    else :
    endif;
    ?>
  • Yeah tried that and still no luck.

    I just added a text sub field called ‘text’ and entered some text in the field.

    Used your code and nothing has shown up on the page.

    <?php
    if( have_rows('layout_section') ):
        while ( have_rows('layout_section') ) : the_row();
            the_sub_field('text');
        endwhile;
    else :
    endif;
    ?>

    For some reason ACF is just not seeing any fields in the repeater field.

  • Strange. Maybe some failure with plugin itself. I think you should write to support and open new ticket. Unless i don’t see something incorrect in your code.

  • had any luck with this? I have the exact same problem.

    I tried writing to support but they aren’t really responding, it’s been 3 days.

    Waste of 100$ 🙁

  • I had my repeater running through another file, to get it to work I had to run it through the repeater again on the page I wanted the repeater to run in the file. Like this.

        <?php if( have_rows('layout_section') ) { } else { } ?>
            <?php wp_reset_query(); ?>
        <?php get_template_part( 'layout-strips' );  ?>

    No idea why this works but it does.

    I would try emailing support as they have been really helpful to me.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.