# Filtering posts on index

**URL:** <https://forum.ghost.org/t/filtering-posts-on-index/14009>\
**Category:** Themes\
**Created:** [May 1, 2020, 7:06pm UTC](https://forum.ghost.org/t/filtering-posts-on-index/14009 "2020-05-01T19:06:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arothberg](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/arothberg/32/7664_2.png) [@arothberg](https://forum.ghost.org/u/arothberg)\
**Post date:** [May 1, 2020, 7:06pm UTC](https://forum.ghost.org/t/filtering-posts-on-index/14009/1 "2020-05-01T19:06:42Z")

</div>

Right now I am iterating over the list of posts on my index page using: `{{#foreach posts visibility="all"}}` and my question is are there other filters that I can pass to the `foreach` that can be used to filter the posts? And is there any documentation for this `visibility` parameter? I don’t see it documented either [here](https://ghost.org/docs/api/v3/handlebars-themes/helpers/foreach/) or [here](https://ghost.org/docs/api/v3/handlebars-themes/context/index/).

---

<div class="post-metadata">

**Author:** ![brightthemes](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/brightthemes/32/25099_2.png) [@brightthemes](https://forum.ghost.org/u/brightthemes)\
**Post date:** [May 1, 2020, 9:09pm UTC](https://forum.ghost.org/t/filtering-posts-on-index/14009/2 "2020-05-01T21:09:14Z")

</div>

Foreach is a context aware helper so the fields depend on the context you are in (post, tag, author).  
You can see the available fields in the post context [here](https://ghost.org/docs/concepts/posts/#sample-api-data)

Additionally there are also some data variables available in a foreach about the current iteration:

- **@index** (number) - the 0-based index of the current iteration
- **@number** (number) - the 1-based index of the current iteration
- **@key** (string) - if iterating over an object, rather than an array, this contains the object key
- **@first** (boolean) - true if this is the first iteration of the collection
- **@last** (boolean) - true if this is the last iteration of the collection
- **@odd** (boolean) - true if the @index is odd
- **@even** (boolean) - true if the @index is even
- **@rowStart** (boolean) - true if `columns` is passed and this iteration signals a row start
- **@rowEnd** (boolean) - true if `columns` is passed and this iteration signals a row end

---

<div class="post-metadata">

**Author:** ![arothberg](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/arothberg/32/7664_2.png) [@arothberg](https://forum.ghost.org/u/arothberg)\
**Post date:** [May 4, 2020, 12:40am UTC](https://forum.ghost.org/t/filtering-posts-on-index/14009/3 "2020-05-04T00:40:04Z")

</div>

Gotcha. Is there any documentation about the context aware filtering that `foreach` does? For example, a value of `all` to `visibility` seems to have special meaning as `all` is [not one of the values that `visibility` can take](https://ghost.org/docs/members/content-visibility/#visibility). (I assume `all` means _any_ value but was wondering if / where this is documented).

Further is it possible to filter by either `tag` or `primary_tag` when using the `foreach` on the list of `posts`? I am looking to add some tag specific lists to the index page (like [Melaka](http://melaka.aspirethemes.com/) does).
