Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Slice blog post in collection

Started by Muut Archive 10 years ago · 4 replies · 412 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 Deleted User, 9 years ago
0 1362 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2959 9 years ago
Archive · by Muut Archive, 9 years ago
3 1124 9 years ago