Hello people,
Imagine the following situation. You’re on an article page (so a ‘single’). This page also displays the categories and tags of this particular article. I would like to show the total amount of articles for each individual category or tag. It should like this: ‘Philosophy (7)’.
It’s easy to get all categories and tags of a particular page, but in that case I can’t find a way to show the count of those categories and tags.
My code looks like this:
{{ range .GetTerms "categories" }}
{{ $category := .LinkTitle | lower }}
{{ $count := .Site.Taxonomies.categories.$category.Count }}
<li>
<a href="{{ .Permalink }}">{{ .LinkTitle }} ({{ $count }})</a>
</li>
{{ end }}
This code however gives an error. So, should I do it just completely differently or is there a way to use custom variables in functions like I tried in my code. Because the logic of that code would be the solution.
Would appreciate any help.