# Filters for channel and collection are not applied

**URL:** <https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695>\
**Category:** Routing\
**Created:** [April 21, 2022, 11:39am UTC](https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695 "2022-04-21T11:39:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenneth\_Roos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kenneth_roos/32/10439_2.png) [@Kenneth\_Roos](https://forum.ghost.org/u/Kenneth_Roos)\
**Post date:** [April 21, 2022, 11:39am UTC](https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695/1 "2022-04-21T11:39:51Z")

</div>

Hi Everyone, could someone explain to me why my filters are not applying correctly?  
I have a collection for “blog” and a channel “release-notes”:

```auto
routes:
   ...
  /release-notes/:
    controller: channel
    filter: tag:release-notes
    template: blog-index

collections:
  /blog/:
    permalink: /blog/{slug}/
    template: blog-index
    filter: tag:blog
    data: tag.blog

```

in the blog-index template I do:

```auto
    {{#get "posts" filter="featured:false" include="authors" order="published_at desc"}}
      {{#foreach posts columns="3"}}

        {{#if @rowStart}}<div class="row">{{/if}}
          {{> third-post-card}}
        {{#if @rowEnd}}</div>{{/if}}

      {{/foreach}}
    {{/get}}

```

I am guessing that since I get all posts here again, that causes my filters not to apply.  
How is this done correctly?

Many thanks in advance.

---

<div class="post-metadata">

**Author:** ![TheRoyalFig](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/theroyalfig/32/27771_2.png) [@TheRoyalFig](https://forum.ghost.org/u/TheRoyalFig)\
**Post date:** [April 21, 2022, 1:09pm UTC](https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695/2 "2022-04-21T13:09:17Z")

</div>

Because your routes already define the data for your `blog-index` page, you can omit the `{{#get}}` helper and loop through the posts directly with `{{#foreach posts}}`. If you want to filter on featured posts, you can either add that filter to your routes file or use the `{{#if}}` helper within the loop.

```nohighlight
filter: tag:blog+featured:false

```

```handlebars
{{#foreach posts}}
  {{^if featured}}
  ...
  {{/if}}
{{/foreach}}

```

Let me know if that works!

---

<div class="post-metadata">

**Author:** ![Kenneth\_Roos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kenneth_roos/32/10439_2.png) [@Kenneth\_Roos](https://forum.ghost.org/u/Kenneth_Roos)\
**Post date:** [April 21, 2022, 1:34pm UTC](https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695/3 "2022-04-21T13:34:04Z")

</div>

Thanks for the reply @TheRoyalFig.  
This works for the featured posts but now I end up with gaps in my columns where a featured post is not redered.  
Do you have another idea?  
Here is my code for reference

```auto
    <div class="row">
      <div class="col-12">
          {{#foreach posts}}
            {{#if featured}}
              {{> row-post-card}}
            {{/if}}
          {{/foreach}}
        </div>
      </div>
      {{#foreach posts columns="3"}}

          {{#if @rowStart}}<div class="row">{{/if}}
            {{^if featured}}
              {{> third-post-card}}
            {{/if}}
          {{#if @rowEnd}}</div>{{/if}}

      {{/foreach}}

      </div>
    </div>

```

---

<div class="post-metadata">

**Author:** ![TheRoyalFig](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/theroyalfig/32/27771_2.png) [@TheRoyalFig](https://forum.ghost.org/u/TheRoyalFig)\
**Post date:** [April 21, 2022, 3:09pm UTC](https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695/4 "2022-04-21T15:09:05Z")

</div>

My first thought is to scrap the custom route and use the `{{#get}}` helper to fetch the posts you need.

But to offer more guidance, I think I’d need to see what you’re trying to accomplish. Can you share a link or screenshot?

---

<div class="post-metadata">

**Author:** ![Kenneth\_Roos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kenneth_roos/32/10439_2.png) [@Kenneth\_Roos](https://forum.ghost.org/u/Kenneth_Roos)\
**Post date:** [April 21, 2022, 3:16pm UTC](https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695/5 "2022-04-21T15:16:27Z")

</div>

I have the blog online here: [Blog - Query.me](https://query.me/blog/)  
I am trying to make a channel with blog posts that are tagged ‘release-notes’.

---

<div class="post-metadata">

**Author:** ![TheRoyalFig](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/theroyalfig/32/27771_2.png) [@TheRoyalFig](https://forum.ghost.org/u/TheRoyalFig)\
**Post date:** [April 21, 2022, 7:17pm UTC](https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695/6 "2022-04-21T19:17:55Z")

</div>

OK!

Do you want the release note posts to show up on /blog, too? Or only on /release-notes/?

And what are you using the row attribute to do? Is it for styling purposes?

---

<div class="post-metadata">

**Author:** ![Kenneth\_Roos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kenneth_roos/32/10439_2.png) [@Kenneth\_Roos](https://forum.ghost.org/u/Kenneth_Roos)\
**Post date:** [April 25, 2022, 10:18am UTC](https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695/7 "2022-04-25T10:18:30Z")

</div>

Yes, in block I would want everything shown that is tagged as “blog”.  
My release-notes are tagges as “blog” and as “release-notes”.  
The row class is part of bootstraps grid layout: [Grid system · Bootstrap](https://getbootstrap.com/docs/4.1/layout/grid/)

---

<div class="post-metadata">

**Author:** ![TheRoyalFig](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/theroyalfig/32/27771_2.png) [@TheRoyalFig](https://forum.ghost.org/u/TheRoyalFig)\
**Post date:** [April 25, 2022, 4:21pm UTC](https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695/8 "2022-04-25T16:21:06Z")

</div>

To create the channel, there’s a couple of different ways to do it.

The easiest is to link to /tag/release-notes. Ghost will automatically create a tag archive there of all your release notes posts.

If you want to create a custom channel, then I’d use a [custom route with a channel controller](https://ghost.org/docs/themes/routing/#channels). You’d want to add the following to your routes.yaml file in Settings \> Labs \> Routes.

```yaml
routes:
  /release-notes/:
    controller: channel
    filter: tag:release-notes

```

---

<div class="post-metadata">

**Author:** ![Kenneth\_Roos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kenneth_roos/32/10439_2.png) [@Kenneth\_Roos](https://forum.ghost.org/u/Kenneth_Roos)\
**Post date:** [April 27, 2022, 10:31am UTC](https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695/9 "2022-04-27T10:31:01Z")

</div>

Hey so, thanks for your help but that is actually how I had it to begin with if you check my initial post.  
The problem is that the filter does not work when I want to seperate featured posts from the rest of them to display them on top.  
I think in the end I will just make two seperate templates: one for all blog posts and one for release-notes only. They will be identical with only the small difference of using a different filter in the #get.

---

<div class="post-metadata">

**Author:** ![TheRoyalFig](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/theroyalfig/32/27771_2.png) [@TheRoyalFig](https://forum.ghost.org/u/TheRoyalFig)\
**Post date:** [April 27, 2022, 1:02pm UTC](https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695/10 "2022-04-27T13:02:46Z")

</div>

Sorry, too, I think I got lost on the thread!

Here’s one other technique you can try.

In your `routes.yaml` file, you can actually return the posts so that featured posts are first, followed by the rest. In your case, that would look like this:

```nohighlight
routes:
  /release-notes/:
    controller: channel
    filter: tag:release-notes
    order: featured desc, published_at desc

```

This will load release-notes posts by featured first, then the rest. Let me know if that works!

---

<div class="post-metadata">

**Author:** ![Kenneth\_Roos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kenneth_roos/32/10439_2.png) [@Kenneth\_Roos](https://forum.ghost.org/u/Kenneth_Roos)\
**Post date:** [April 29, 2022, 12:19pm UTC](https://forum.ghost.org/t/filters-for-channel-and-collection-are-not-applied/29695/11 "2022-04-29T12:19:08Z")

</div>

Cool yeah this actualy works! Thanks a lot!
