2

Is there a way to paginate events entries without setting an expiry date for each entry? So I currently have:

{% paginate craft.entries.section('eventsEntry').limit(3).orderBy('eventDate') as pageInfo, upcomingEvents %}

{% for event in upcomingEvents if event.eventDate >= now %}     
...
{% endfor %} 

But this will include past events in the loop but not show them when output. Which results in empty 'slots' on the first page.

2

You need to include an extra parameter in your initial query to only fetch event entries for events in the future and remove the conditional test from the for loop.

Currently you are fetching all event entries and paginating those, but only displaying event entries where the eventDate is in the future.

Try this instead:

{% paginate craft.entries.section('eventsEntry').limit(3).eventDate('>=' ~ (now | date('Y-m-d H:i'))).orderBy('eventDate') as pageInfo, upcomingEvents %}

{% for event in upcomingEvents %}     
...
{% endfor %} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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