# Slicing loops

In many cases you may want to display a specific post or posts from your data source. We do this by applying a "slice" filter to the **feedotter.posts** element.&#x20;

## Slicing Syntax

Slicing is a Filter that is applied to a loop of FeedOtter posts.

```
[% for post in feedotter.posts | slice(0,1) %]
```

The "slice" filter accepts one or two parameters and works like this:

```
slice(3) // Start at the first post and loop 3 times. Displays post 1,2,3
slice(0,3) // Same as the first. Start at the first post and loop through 3 times. Displays post 1,2,3
slice(3,3) // Start looping at post 3 and loop 3 times.  This will display post 3,4,5
```

## More Examples

<pre><code><strong>// Start looping at the first post(0) and stop after 1 post.
</strong><strong>[% for post in feedotter.posts | slice(0,1) %]
</strong>    	[[post.post_title]]
    	[[post.post_url]]
    	[[post.post_description_text]]
[% endfor %]
</code></pre>

```
// Skip post 1. Start looping with the second post(1). Stop after 4 posts
[% for post in feedotter.posts | slice(1,4) %]
    	[[post.post_title]]
    	[[post.post_url]]
    	[[post.post_description_text]]
    [% endfor %]
```

{% hint style="info" %}
When working with the feedotter.posts loop syntax.  0 is the index of the first post for the purpose of using Filters.
{% endhint %}

{% hint style="warning" %}
Using the slice filter will override the Number of Posts UI dropdown. &#x20;
{% endhint %}

Pay special attention to the | slice(0,1) part of the loop definition. The first number in the slice() function is the starting point so 0=first post in a data source. The second number is the length or number of posts to display or loop through.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.feedotter.com/set-up-your-own-template/advanced-template-information/slicing-loops.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
