Home › Forums › Add-ons › Repeater Field › Output Repeater In Two Columns › Reply To: Output Repeater In Two Columns
personally, I would show this in one list and float the <li>
elements left. Possibly add an odd
an even
class so that I could add a clear left on the odd
ones. This way on a really narrow screen they would still be listed in the correct order.
As for your question, something like this
if (have_rows('repeater')) {
$column_1 = array();
$column_2 = array();
$count = 0;
while (have_rows('repeater')) {
the_row();
if ($count % 2 == 0) {
$column_1[] = get_sub_field('sub_field');
} else {
$column_2[] = get_sub_field('sub_field');
}
$count++;
}
}
// now create your ul elements and loop through each array
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.