Support

Account

Home Forums Add-ons Repeater Field Repeater field split in 2 columns Reply To: Repeater field split in 2 columns

  • I figured it out

    Code is wrong on 2nd part.
    if (($i++ % 2) == 0 ) should be if (($i++ % 2) != 0 )

    And one line was missing in the middle $i = 0; rewind_posts();

    So in the end, general code is :

    <?php 
    $i = 0;
    $rows = get_field('articles_de_presse');
    	echo '<div class="odd-column">' ;
    		foreach($rows as $row) {
    			if (($i++ % 2) == 0 ) { 
     				echo '<div class="actupost"><h3>' . $row['auteur_de_larticle']  . '</h3><div class="actuexeprt">'. $row['contenu_de_larticle'] .' </div></div>';
    			}
    		}
    	echo '</div>' ;
    $i = 0; rewind_posts();
    $rows = get_field('articles_de_presse');
    	echo '<div class="even-column">' ;
    		foreach($rows as $row) {
    			if (($i++ % 2) != 0 ) { 
    				echo '<div class="actupost"><h3>' . $row['auteur_de_larticle']  . '</h3><div class="actuexeprt">'. $row['contenu_de_larticle'] .' </div></div>'; 
    			}
    		}
     	echo '</div>' ;?>