Home › Forums › Add-ons › Repeater Field › Output Repeater In Two Columns Sorted Alphabeticaly › Reply To: Output Repeater In Two Columns Sorted Alphabeticaly
Hi James
Further to my last post, I finally made it work. I tried using the code on that page yesterday, but I must of been tired, because this morning and made it work. There may of been a small amount dancing around the room
(see below)
<ul class="col-md-6">
<?php $i = 0; $j = count( get_field('suppliers_table') );
$repeater = get_field('suppliers_table');
$order = array();
foreach( $repeater as $i => $row ) {
$order[ $i ] = $row['company'];
}
array_multisort( $order, SORT_ASC, $repeater );
if( $repeater ): ?>
<?php foreach( $repeater as $i => $row ): ?>
<li class="supplier_link">
<a href="<?php echo $row['company_url']; ?> "target="_blank"><?php echo $row['company']; ?></a>
</li>
<?php if ( ( $i + 1 ) == ceil($j / 2) ) echo '</ul><ul class="col-md-6">'; ?>
<?php $i++; endforeach; ?>
<?php endif; ?>
</ul>
Only been at this fro two days.
I still don’t understand why the function in functions.php is not working. Is there anyway to see if anything is conflicting with it?
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.