Support

Account

Home Forums General Issues Repeater field Image and Text not rendering in basic loop

Solved

Repeater field Image and Text not rendering in basic loop

  • I’ve used Repeater fields before but it’s not working properly. It’s just outputting empty divs.

    Here’s my code:

    <div class="masonry">
            <?php
    
            // check if the repeater field has rows of data
            if( have_rows('card') ):
    
                // loop through the rows of data
                while ( have_rows('card') ) : the_row();
    
                    // display a sub field value
                   ?> <div class="brick">
                        <h1> test  <?php echo get_sub_field('card-title'); ?> </h1>
                        <img src="<?php echo get_sub_field('card-picture');?>">
    
                    </div> <?php
    
                endwhile;
    
            else :
    
                // no rows found
    
            endif;
    
            ?>
    
        </div>  <!-- masonry -->

    And here’s what my fields look like:

    none

    http://i.imgur.com/0R2Jg7Xr.png

  • You have - // dash in your get_sub_field calls and these are _ // underscore in your field names in ACF.

  • I am such an idiot. I’m sorry I even bothered yall with this basic of an issue. Ugh! I need to get better at checking my syntax.

  • Sometimes it just takes another set of eyes, don’t be sorry. Me being able to see that error so quickly should tell you that I’ve made the same mistake myself, and it was quite frustrating looking at code and not being able to figure out what was causing it. The human brain is a funny thing, a lot of times it sees what it expects to see rather than what’s really there.

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

The topic ‘Repeater field Image and Text not rendering in basic loop’ is closed to new replies.