fling
March 29, 2019, 2:53pm
1
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!
naz
April 11, 2019, 3:17pm
2
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:
Cheers!
1 Like
fling
April 11, 2019, 6:26pm
3
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.
Fred
April 12, 2019, 7:18am
4
You can sort as followed.
{{#get 'tags' limit='all' include='count.posts' order='count.posts desc'}}
2 Likes
system
Closed
April 26, 2019, 7:19am
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.