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>' ;?>
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.