Home Forums Add-ons Repeater Field Order by date, repeater field


Order by date, repeater field

  • Hi Elliot,
    Is there a easy way to sort posts by datepicker field? I manage to order by date within one post. But if there are more rows it will only sort inside that array. I have multiple dates in a post created by repeater field. I need to order them all… See array bellow.

    array(2) { 
    [0]=> array(3) { 
    ["event_start"]=> string(8) "20140111" ["event_end"]=> string(16) "20140112" ["url"]=> string(62) "" 
    [1]=> array(3) { 
    ["event_start"]=> string(8) "20140102" ["event_end"]=> string(16) "20140103" ["url"]=> string(62) "" 
  • Hi @eiriksk

    Thanks for posting your repeater field data.

    I have written a tutorial on how to sort a repeater field here:

    I don’t quite understand what you mean by ordering based on multiple dates per row. Perhaps you can explain the logic you want to achieve?


  • I use ACF to post consert events. In each post I add playing times using repeater field with date picker. So each event can have multiple dates.

    I manage to order one post by playing dates. But my question is how to sort many posts with different playing times. Order them chronology.

    Actually you reapeat the post content, but with different date.

  • Hi @eiriksk

    This will not be possible with any WP_Query args, so you will need to do this custom ordering with custom PHP logic.

    Firstly, load the posts via the get_posts function, and then loop over them.
    For each post, load in the playing dates data and use this data to construct an array where one of the columns is the playing time.

    Then you can use the code in the above tutorial to sort this custom array based on the playing time.

    Good luck


Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Order by date, repeater field’ is closed to new replies.