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>
        if( get_row_index() % 4 == 0  ){
            // Close the div and open it again
            echo "</div><div>";
            <?php endwhile; ?>
        <div> <!-- This is the closing -->
    <?php endif; ?>

    I hope this helps 🙂