List entries using Twig and exclude latest (for exmple 5)

340 Views Asked by At

I'm using Bolt cms for my new website and I want to display an overview of entries (news items). That list must have all the entries except for the latest 5 items. I'm fairly new with it, so I'm not familiar with all the possibilities Twig has.

I can use a % for % loop to skip the latest entries. But I don't know the exact code for this. Can someone help me and explain why the used code is used?

1

There are 1 best solutions below

2
On

First, get a bunch of entries:

{% setcontent lastentries = "entries/last/10" %}

Then use a for loop to take only the last five out of ten:

{% for entry in lastentries|slice(5,9) %}

Note that slice slice starts at '0', instead of '1'.