Home » Topics » General Support » Repeater

Repeater

ACF Widgets Support General Support Repeater

This topic contains 3 replies, has 2 voices, and was last updated by  Daron Spence 2 months, 1 week ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #103440

    Sylvain Lapierre
    Participant

    Hi there,

    can give me an example with repeater field ?

    I try somethine like that and nothing happening.

    <?php if( have_rows('partners_logos', $acfw) ): ?>
    	<?php while( have_rows('logo', $acfw) ): the_row();
    		   // vars
              	   $logo = get_sub_field('logo', $acfw);
    		?>
                    <div class="col-md-6">
    			<img src="<?php the_sub_field('logo', $acfw); ?>" alt="" class="img-responsive">
    		</div>
    	<?php endwhile; ?>
    <?php endif; ?>
    #103441

    Sylvain Lapierre
    Participant

    That is my current try :

    <?php if( have_rows('partners_logos, $acfw') ): ?>
    	<?php while( have_rows('partners_logos, $acfw') ): the_row(); ?>
                    <div class="col-md-6">
    			<img src="<?php the_sub_field('logo', $acfw); ?>" alt="" class="img-responsive">
    		</div>
    	<?php endwhile; ?>
    <?php endif; ?>
    #103442

    Sylvain Lapierre
    Participant

    I found my mistakes..

    #103443

    Daron Spence
    Keymaster

    Sylvain, you’re really close! Looks like there is a syntax error in your have_rows() checks. The $acfw part is a PHP variable that needs to be passed as another argument to the function. Your single quotes were in the wrong place. Check out this gist of the correct syntax.

    Please note that while the syntax in the gist is correct, if your fields are not referenced correctly, you still won’t see anything. Most of the time it’s a simple spelling mistake.

    Also, you don’t need to use have_rows() on a subfield (your first iteration).

    Hope this helps & thanks for supporting the plugin!

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

You must be logged in to reply to this topic.