Filter tags containing more than 5 posts

Hello Ghosts

I have a “tags” page where I want to see the main tags :

          {{#get 'tags' limit='all' include='count.posts' order='count.posts desc'}}
                {{#foreach tags visibility="public"}}
                    {{> "tag-card"}}
                {{/foreach}}
            {{/get}}

I would like to display only tags containing more than 5 posts. Is it possible?

By the way, the post count is global. If a tag contains 10 “member only” posts and 1 public, a non-member will see 11 posts and only one will show up when he goes to the tag page.

I understand that “get tags” function cannot do that?

Thanks

I don’t think you can do it with get directly.

But you can use a simple CSS trick:

In your tag card add a CSS class tag-card-count-{{count.posts}}

Then in your CSS use :

        .tag-card-count-0,
        .tag-card-count-1,
        .tag-card-count-2,
        .tag-card-count-3,
        .tag-card-count-4 {
            display: none;
        }
1 Like

Thanks, it’s a nice workaround, I will implement that!

Now that I think about it, you can also use the match helper

{{#get 'tags' limit='all' include='count.posts' order='count.posts desc'}}
    {{#foreach tags visibility="public"}}
        {{#match count.posts ">=" 5}}
            {{> "tag-card"}}
        {{/match}}
    {{/foreach}}
{{/get}}
3 Likes

Perfect, it works!

https://blog.iero.org/tags/

Thanks a lot

1 Like