# Displaying the post count for each tag

**URL:** <https://forum.ghost.org/t/displaying-the-post-count-for-each-tag/6523>\
**Category:** Developer help\
**Created:** [March 29, 2019, 2:53pm UTC](https://forum.ghost.org/t/displaying-the-post-count-for-each-tag/6523 "2019-03-29T14:53:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fling](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/fling/32/3002_2.png) [@fling](https://forum.ghost.org/u/fling)\
**Post date:** [March 29, 2019, 2:53pm UTC](https://forum.ghost.org/t/displaying-the-post-count-for-each-tag/6523/1 "2019-03-29T14:53:38Z")

</div>

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 }}
    {{name}}
    {{plural ../pagination.total empty='posts' singular='% post' plural='% posts'}}
  {{/foreach}}
{{/get}}

```

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?

Thanks!

---

<div class="post-metadata">

**Author:** ![naz](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/naz/32/30666_2.png) [@naz](https://forum.ghost.org/u/naz)\
**Post date:** [April 11, 2019, 3:17pm UTC](https://forum.ghost.org/t/displaying-the-post-count-for-each-tag/6523/2 "2019-04-11T15:17:43Z")

</div>

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:

> **[Ghost Handlebars Theme Helpers: get](https://ghost.org/docs/themes/helpers/get/)**
>
> Make custom queries to the Ghost API using the get helper and fetch publicly available data. Read more about Ghost themes! 👻

Cheers!

---

<div class="post-metadata">

**Author:** ![fling](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/fling/32/3002_2.png) [@fling](https://forum.ghost.org/u/fling)\
**Post date:** [April 11, 2019, 6:26pm UTC](https://forum.ghost.org/t/displaying-the-post-count-for-each-tag/6523/3 "2019-04-11T18:26:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Fred](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/fred/32/3146_2.png) [@Fred](https://forum.ghost.org/u/Fred)\
**Post date:** [April 12, 2019, 7:18am UTC](https://forum.ghost.org/t/displaying-the-post-count-for-each-tag/6523/4 "2019-04-12T07:18:24Z")

</div>

You can sort as followed.

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/b/ba9ce5100b8bb264586f4f572545596b2ce3f081.png) [@system](https://forum.ghost.org/u/system)\
**Post date:** [April 26, 2019, 7:19am UTC](https://forum.ghost.org/t/displaying-the-post-count-for-each-tag/6523/5 "2019-04-26T07:19:29Z")

</div>

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