Support

Account

Home Forums Add-ons Repeater Field Repeater sorted by Date Reply To: Repeater sorted by Date

  • I think this is on the right track but I am getting this error.
    Did I miss something in your example?

    Fatal error: Function name must be a string

    this is my code

    <?php
                 
                 $repeater = get_field('race_event');
                 foreach( $repeater as $key => $row )
                   { 
                     $column_id[ $key ] = $row['race_date'];
                   } 
                   array_multisort( $column_id, SORT_ASC, $repeater );
                   
                   $currMonth = "start";
                   foreach( $repeater as $row ) :
                   {
                     $date = DateTime::createFromFormat('Ymd', $row['race_date']); 
                     $website_url = $row['race_website'];
                     
                     if ($currMonth != $date('F')) :
                       {
                         echo '<h2>' . $date('F') . '</h2><br>';
                         $currMonth = $date('F');
                       }
                     endif;
                     
                     echo '<ul>';
    		               echo '<li><h2>' . $row['race_name'] . '</h2></li>';
    		               echo '<li>Date ' . $date->format('F d, Y') . '</li>';
    		               echo '<li>Distance ' . $row['race_distance'] . '</li>';
    		               echo '<li>Vertical ' . $row['race_vertical'] . '</li>';
    		               echo '<li>URL <a href=' . $website_url . '> ' . $website_url . ' </a></li>';
    		               echo '<li>' . $row['race_description'] . '</li>';
    		             echo '</ul>';
                   }
                   endforeach;
                   ?>