Sorting blog entries by year

Hello, I am trying to sort blog articles on a single page by year.

The second example linked here seems to work perfectly well, however, instead of the current year $year = date('Y'); I would like to use the range of years from the blog articles’ date fields.

Is this something someone may be able to help me learn how to do? Thank you.

The example you linked to is about filtering, but you want to sort them? Or do you mean group by year? And what does range of years mean?

I think you’re right—that I’d like to sort them rather than filter. This example is probably closer to what I’m after. I’m hoping to make a kind of list or index for each year so that all of the 2022 articles are together, the 2021 articles are together, and so forth.

Yes! Grouping by year is what I mean to say :slight_smile:

1 Like

Then this example is what you need: Grouping collections | Kirby CMS

And welcome to the forum :wave:

Thank you very much Sonja!