Support

Account

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