So I need to use the repeater field in ACF to output a section of my website. The way I have it set up it creates a new <div class="row landing-item">
every time its called. I need it to create that every 2 times so the html will be correct for the layout.
<section class="row landing">
<h2>Featured Sections</h2>
<?php if( have_rows('landing_page_landing_items') ): ?>
<?php while ( have_rows('landing_page_landing_items') ) : the_row(); ?>
<div class="row landing-item">
<div class="small-12 medium-6 columns">
<img src="<?php the_sub_field('landing_image'); ?>">
<h3><?php the_sub_field('landing_title'); ?></h3>
<p><?php the_sub_field('landing_text'); ?></p>
<a class="button" href="<?php the_sub_field('landing_link'); ?>">Learn More</a>
</div>
</div><!-- end landing-item -->
<?php endwhile; ?>
<?php endif; ?>
If you look at the above the end result I need is a row with 2 columns, then row with 2 columns and so on and so on. Again right now it gives me a row with 1 column every time. I tried moving about the script initiations outside and inside the rows and columns but could not get the right sequence.
It looks like you may be able to accomplish your end goal by using the Foundation Block Grid feature rather than the standard grid. If you use the block grid, You'll continue to repeat row after row based only on the number of items in the list. See below:
<section class="row landing">
<h2>Featured Sections</h2>
<div class="row landing-item">
<ul class="small-block-grid-1 medium-block-grid-2">
<?php if( have_rows('landing_page_landing_items') ): ?>
<?php while ( have_rows('landing_page_landing_items') ) : the_row(); ?>
<li>
<img src="<?php the_sub_field('landing_image'); ?>">
<h3><?php the_sub_field('landing_title'); ?></h3>
<p><?php the_sub_field('landing_text'); ?></p>
<a class="button" href="<?php the_sub_field('landing_link'); ?>">Learn More</a>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div><!-- end all landing items -->
</section>
You may need to do some CSS if you'd need to do any special per row editing. I'm thinking this may be one solution to your dilemma though.