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 →

Slice blog post in collection

Started by Muut Archive 10 years ago · 4 replies · 527 views
10 years ago

How can i slice a particular post if i want to show only 5 number of post and if i want to show post only 7, 8, 9 then how we set slice i have used something like that

TWIG
  For three post {% for ps in taxonomy.findTaxonomy({'category':'World'})|slice(8, 10) %}
  For Single post {% for ps in taxonomy.findTaxonomy({'category':'World'})|slice(5,) %}

Anyone can help me
Thanks

10 years ago

if we want to show only one like 5th number of post then how we set

10 years ago

it's an array so simply pull the 5th one remebering arrays are zero-based indexed so the index is 4 for the 5th item:

TWIG
{{ my_array[4] }}
10 years ago

Sorry we put like this but its not working
{% for ps in taxonomy.findTaxonomy({'category':'World'})|slice(5,) %}

Suggested topics

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