3

I have a site where I want to feature the latest 5 entries and show the next 10 in a separate list. How would I do this?

The first part would be easy: craft.entries.section('news').limit(5)

But I can't figure out how to bring the next 10. Any suggestions?

5

I believe you're looking for offset.

So if you want entries 6-15 it would be:

craft.entries.section('news').offset(5).limit(10)
|improve this answer|||||
6

In the way you have described that you want to use all the results on the page but just moved and used in chunks you should save a query on the database and use slice over offset.

{% set entriesList = craft.entries.section('news').limit(15) %}

{# Featured #}
{% for entries in entriesList | slice(0, 5) %}
{% endfor %}

{# Other List#}
{% for entries in entriesList | slice(4, 10) %}
{% endfor %}
|improve this answer|||||
  • Answer from jnowladn using slices above works but note that it has a type you need to correct first - he calls 'entriesList' and then refers to it as 'entriesLists' in the slices which won't work - they need to be called the same thing. Slices are ace, saved me a bit of head scratching on listings pages. – Allen O'Leary Jul 24 '17 at 15:23

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.