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 →

For loop order by date

Started by Muut Archive 11 years ago · 4 replies · 544 views
11 years ago

Is it possible to render pages with a {% for lil_foo in foo.children %} in date order, like newest to oldest?

11 years ago

Yup, it's just:

TWIG
{%for lil_foo in foo.children.order('date', 'desc') %}
11 years ago

ok, next level.. what if i need to return all the second level child of a page with a for loop in date order.. ? :/

11 years ago

your going to have to put another loop in side that first loop. have a look at the macro in the partials/navigation.html.twig in the Antimatter theme to see how you can do this recursively.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Muut Archive, 10 years ago
1 673 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