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>
                        <?php if ( ( $i + 1 ) == ceil($j / 2) ) echo '</ul><ul class="col-md-6">'; ?>
                    <?php $i++; endforeach; ?>
                <?php endif; ?>

    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?