2

Assuming that I’ve a total number of 10 entries in my section('exhibitions') where 8 of them have their entry.endingDate < now, I limit the display to 8 entries but the paginate shows a next button whereas the next page is empty:

{% paginate craft.entries.section('exhibitions').limit(8) as pastExhibitions %}
    {% for entry in pastExhibitions %}
        {% if entry.endingDate < now %}
            …
        {% endif %}
    {% endfor %}

    {% if paginate.prevUrl %}
        <a href="{{ paginate.prevUrl }}" class="button previous">&larr; Précédent</a>
    {% endif %}
    {% if paginate.nextUrl %}
        <a href="{{ paginate.nextUrl }}" class="button next">Suivant &rarr;</a>
    {% endif %}

{% endpaginate %}

How can I add a date filter, in this case < now, to the paginate configuration in order to only paginate on entries that are < now?

3
{% paginate craft.entries.section('exhibitions').endingDate('< ' ~ now).limit(8) as pastExhibitions %}
  ...
{% endpaginate %}

This will paginate the entries in section exhibiitions with endingDate < now. That ~ is string concatination operator. The string '< 2014-08-04' queries for entries with endingDate in the past.

| improve this answer | |

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.