Displaying the post count for each tag

I’m trying to display the number of posts for each tag on a Blog Collection page. e.g.

  • Alpha Tag (2 posts)
  • Bravo Tag (4 posts)
  • Charlie Tag (3 posts)

Here is the code I tried…

{{#get "tags" limit="6"}}
  {{#foreach tags }}
    {{plural ../pagination.total empty='posts' singular='% post' plural='% posts'}}

I only get the total number of posts for the blog, not the tag. I assume the pagination helper doesn’t work in this context. Is there another way to get the post count?


Hi @fling. You can try using “include” parameter with “count.posts” value to get post count for each of the tags like described in Ghost docs here:


1 Like

That worked perfectly. Thanks!

Followup question – is it possible to sort a list of tags by count (or anything)? The sort of items seems arbitrary.

You can sort as followed.

{{#get 'tags' limit='all' include='count.posts' order='count.posts desc'}}


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.