ACF Relationship Loop orderby/sort using event date field

Hi,

I am trying display a list of related events using and ACF relationship field. I was to display a list of events that shows related events ordered by event date, more recent or upcoming at the top and older/past at the bottom. I was looking through documentation and found something like this, however it’s not ordering. So something isn’t right, any insights on that would be appreciated.

<Loop acf_relationship="related_events" sort_field="_eventorganiser_schedule_start_start" sort_type="date" sort_date_format="d-m-Y" sort_order="desc">
  <li><a href="{Field url}"><Field title /></a> - <Date format="l, F j, Y"><Field _eventorganiser_schedule_start_start /></Date> at <Date format="g:i a"><Field _eventorganiser_schedule_start_start /></Date></li>
</Loop>

Also if there’s a way I can show two lists, with future events and another of past events that would be great. As shown in documentation here.

<Field type=event custom_date_field=event_date_time custom_date_field_format="Y-m-d H:i:s" custom_date_field_compare=before custom_date_field_value=current

How would I incorporate that to the loop?

Thanks!

Hi @danaskallman! I just wrote up a whole response explaining that I’m able to use your exact template on my WordPress installation and it works fine, but then I noticed that I was running the previous version of L&L (2.4.4). I updated to the latest version (3.0.0) and then it stopped working. So the good news is that I was able to confirm that your markup is correct, but it seems like it simply isn’t working in the latest version of the plugin. I’ve passed my findings along to the dev team so I’m sure they’ll address this in an update.

In the second part of your post, I noticed that the example starts with Field type=event... which isn’t right. This was my mistake when I wrote up that example in the post loop documentation and it should have been Loop type=event.... As far as how you’d incorporate that into your loop, this may seem obvious now that I’ve clarified my mistake but it would just be a matter of adding those query parameters to your other Loop tag. I’m not able to test this at the moment because of the issue mentioned above, but I’ll keep this on my to-do list and follow up here with clarifications.

2 Likes

Hi @benjamin and @danaskallman !
I’m chiming in here because I think I’m running into a similar issue as I’m trying to sort using an acf_date_time parameter, and can’t seem to make it work. Is there any update on the issue? Is it supposed to be solved or is it still hanging?

Hi @Adrien_C, the great and powerful @eliot wasn’t able to address this in time for the 3.0.1 release but it’s being investigated and I’m sure it’ll be addressed in an upcoming update. I’ll be sure to post here when the fix gets scheduled for release.

1 Like