Home › Forums › Add-ons › Flexible Content Field › Random Flexible Content Field Results Ordering › Reply To: Random Flexible Content Field Results Ordering
I used this code for sort my flexible content. Basic is the same code for repeater.
<?php
$acontecimentos = get_field('acontecimentos');
$date = [];
//Reorder
foreach($acontecimentos as $key => $row) {
$date[$key] = $row['data'];
}
array_multisort($date, SORT_ASC, $acontecimentos);
foreach($acontecimentos as $row) {
if($row['acf_fc_layout'] == 'galeria'):
//code
endif;
}
?>
After array_multisort you can use shuffle http://us3.php.net/manual/en/function.shuffle.php
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.