Get post using filter tag's slug is not woking

Ghost version Latest

I am trying to get such post that are associated with such primary tag’s slug

 {{#get "tags" limit="all"}}
      <h2 class="text-dark fw-bold mb-lg-5 mb-3">{{slug}}</h2>
      {{#get "posts" limit="all" filter="tag:{{slug}}"}}
           {{#foreach posts}}
                <a href="{{url}}" class="text-secondary">{{title}}</a>
           {{/foreach}}
      {{/get}}

which gives me empty post

without filer, it gives me all the posts

any idea?

I just saw this post - are you still having trouble?

You’re getting the tags data at the start, but I don’t see where you’re looping through it. Did you intend to loop through it with a foreach?
So, if your tags are apples, bananas, kiwi, do you want all the posts tagged apples, then all the posts tagged bananas, etc?

Btw, you can specify primary tag, if that’s what you want. Ghost Handlebars Theme Helpers: get

You might want to look at how Headline does this - specifically home.hbs. I think it does what you’re trying to do, but maybe I don’t understand what you’re trying to do.

1 Like

By default, the {{get}} helper will only fetch the basic data of the post, and that doesn’t include tags and authors, that is why your filter doesn’t work.

You should extend it using the include attribute

{{#get "posts" limit="all" include="tags" filter="tag:{{slug}}"}}
1 Like