Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Get children pages by creation date, not modified date

Started by Muut Archive 10 years ago · 1 replies · 716 views
10 years ago

I'm trying to get the 3 most recent blog posts by creation date with the following
page.find('/blog').children.order('date', 'desc').slice(0, 3)
but if I modify an old post it gets in first place.

Any idea how I can achieve that?

10 years ago

Alright, got it to work with this
{% set posts = page.find('/blog').children.slice(1).slice(-3).reverse() %}

Get the last 3 new posts and reverse them so I can show them from newest to oldest.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Muut Archive, 10 years ago
1 672 1 week ago
Archive · by Deleted User, 9 years ago
0 3043 9 years ago
Archive · by Muut Archive, 9 years ago
2 1983 9 years ago
Archive · by Muut Archive, 9 years ago
2 5336 9 years ago
Archive · by Muut Archive, 9 years ago
1 4134 9 years ago