I have an archive of exhibitions with entries grouped by year. The order of the groups should be descending, the order of the entries within the group should be ascending.

For example: The order of the years should be 2018, 2017, 2016, … The entries within the group 2018 should start with the first exhibition of the year and end with the last one.

Here is my code:

{% set archive = craft.entries.section("exhibitions").order('dateStart desc').dateEnd('<' ~ now).limit(null)  %}
{% set archiveGrouped = archive|group('dateStart.year') %}
{% for year, entriesInYear in archiveGrouped %}
    <h2 class="year">{{ year }}</h2>
    {% for entry in entriesInYear %}

And the link to the Website: https://kunsthausbaselland.ch/en/ausstellungen

I guess there is an easy solution for this. But I couldn’t figure it out and found nothing in the docs.


Assuming the years are currently rendered in the correct (descending) order, an easy way to make sure the entries are rendered in ascending order would be to simply reverse the entriesInYear array, i.e.:


{% for entry in entriesInYear|reverse %}
{% endfor %}
  • 1
    Jop, that works. I knew it’s gonna be an easy solution. :) Thanks a lot for the fast help! Jul 24 '18 at 18:48

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.