2

I'm trying to paginate a bunch of events based on their start date. The order part is working correctly, but each consecutive page just loads the exact same entries. My code:

{% set events = craft.entries().section('events').limit(2).order('startDate asc') %}
{% paginate events as pageInfo, pageEntries %}

{% for event in events %}
    // Event content
{% endfor %}

{% if pageInfo.prevUrl %}<a href="{{ pageInfo.prevUrl }}">Previous Page</a>{% endif %}
{% if pageInfo.nextUrl %}<a href="{{ pageInfo.nextUrl }}">Next Page</a>{% endif %}

What am I missing?

2

Pulling it all inside paginate fixed it:

{% paginate craft.entries().section('events').limit(2).order('startDate asc') as events %}

{% for event in events %}
    // Event content
{% endfor %}

{% if paginate.prevUrl %}<a href="{{ paginate.prevUrl }}">Previous Page</a>{% endif %}
{% if paginate.nextUrl %}<a href="{{ paginate.nextUrl }}">Next Page</a>{% endif %}

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.