I'm using Advanced Custom Fields, and I would like to wrap every 3 divs in a row. If there is a fourth div or 2 extra then those would get wrapped in their own row. So open and close with a row.
I currently have the basic output but all my current attempts to add the counter have failed. Any help would be appreciated
<?php // wrap every 3 divs in a row
if(get_field('triple_column_2')): ?>
<?php while(has_sub_field('triple_column_2')): ?>
<div class="col-sm-4">
<?php the_sub_field('copy'); ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
You can use this as a starting point. I haven't tested it so there might be slight problems in my logic, but this will get you most of the way there (if not all the way!).