2

I have an event section with custom fields for eventDate and eventEndDate.

I'm listing upcoming events in my template using:

{% for event in craft.entries.section('events').eventDate('>='~now).limit(3).order('eventDate ASC') %}

This works fine for single day events. But multi-day events disappear after the first day, when I want them to be listed until the event is over. I can't do .eventEndDate('>='~now) because the Event End Date field is left blank for single day events. Is there a way to add an OR to my query to get events with future eventDates OR events with future eventEndDates?

1 Answer 1

3

I think the simplest solution would be to make the eventEndDate field required even for single day events. Then you could do something like this:

{% for event in craft.entries({
  section:'events', 
  eventEndDate:'>= '~now,
  limit: 3, 
  order:'startDate'
}) %}

Given you have 3 events:

  1. Starts Monday, ends Friday.
  2. Starts Wednesday, ends Thursday.
  3. Starts Thursday, ends Thursday.

On Wednesday, you'll still see those events in order (1,2,3).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.