Home › Forums › Add-ons › Repeater Field › Grid based layout and repeater help needed › Reply To: Grid based layout and repeater help needed
Hi @tombyrom
I think you can use the modulus operator and the get_row_index() function to check if it is the 4th column of the grid. It should be something like this:
<?php if( have_rows('factsheets') ): ?>
<div> <!-- This is the opening -->
<div class="vc_row wpb_row vc_row-fluid dt-default" style="margin-top: 0px; margin-bottom: 0px; min-height: 0px;">
<?php while( have_rows('factsheets') ): the_row();
// vars
$factsheet_title = get_sub_field('factsheet_title');
$factsheet_pdf = get_sub_field('factsheet_pdf');
?>
<div class="wpb_column vc_column_container vc_col-sm-3">
<div class="vc_column-inner ">
<div class="wpb_wrapper">
<a href="<?php echo $factsheet_pdf['url']; ?>"><img src="/pdf-logo.png" /></a>
<span><?php echo $factsheet_title; ?></span>
</div>
</div>
</div>
<?php
if( get_row_index() % 4 == 0 ){
// Close the div and open it again
echo "</div><div>";
}
?>
<?php endwhile; ?>
</div>
<div> <!-- This is the closing -->
<?php endif; ?>
I hope this helps 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.