sort acf repeater field alphabetically

Solutions on MaxInterview for sort acf repeater field alphabetically by the best coders in the world

showing results for - "sort acf repeater field alphabetically"
Giovanni
29 Feb 2019
1<?php 
2// Get repeater value
3$repeater = get_field('traditional_dining');
4
5// Obtain list of columns
6foreach ($repeater as $key => $row) {
7	$the_website[$key] = $row['website'];
8	$the_name[$key] = $row['name'];
9	$the_address[$key] = $row['address'];
10	$the_phone_number[$key] = $row['phone_number'];
11	$the_map_url[$key] = $row['map_url'];
12}
13
14// Sort the data by restaurant name column, ascending
15array_multisort($the_name, SORT_ASC, $repeater);
16
17// Display newly orded columns
18// Unsure if this is the optimal way to do this...
19foreach( $repeater as $row ) { ?>
20<div class="biz-module">
21	<h2><a href="<?php echo $row['website']; ?>" title="Visit the website for <?php echo $row['website']; ?>"><?php echo $row['name']; ?></a></h2>
22	<h3><a href="<?php echo $row['map_url']; ?>" title="Find <?php echo $row['name']; ?> on the map"><?php echo $row['address']; ?></a></h3>
23	<h4><?php echo $row['phone_number']; ?></h4>
24</div>
25<?php } ?>
similar questions
queries leading to this page
sort acf repeater field alphabetically