Your sites Log in Sign up Menu

Only show tags with a minimum number of posts?

Is there a way to show a list of tags only if there's a minimum number of posts (say three) tagged as such?

I'm looking to do this to show a list of tags without cluttering it up too much and only showing those with a minimum number of tagged posts.

Thanks. Ray


9 months ago, 6 replies   developers   tags   Improve this question

I think you can use the entries.length property of each tag, along with some CSS to accomplish this, e.g.

{{#all_tags}}
<a 
  href="/tagged/{{slug}}" 
  class="total-tagged-{{entries.length}}">
  {{tag}}
</a>
{{/all_tags}}
<style>
.total-tagged-0,
.total-tagged-1,
.total-tagged-2,
.total-tagged-3 {display:none}
</style>
Answered a year ago · Improve this answer

Worked beautifully!

Ray

Answered a year ago · Improve this answer

How about if I want all/specific tags to be displayed instead on the home page? My template is magazine

Answered 9 months ago · Improve this answer

If you remove the class 'clip-tags' from line 29 of the magazine template's header.html file, then replace popular_tags with all_tags you should see every tag used in the sidebar

Answered 9 months ago · Improve this answer

Thanks! What if I have six tags but I want, say, 4 of them to be displayed instead

Answered 9 months ago · Improve this answer

I'd just remove the template logic and simply hard-code the tags you'd like in the menu, e.g.

<div class="mt5 mb5">
  <a href="/tagged/apple"  class="no-underline no-wrap db f3 fw3 black-50">Apple</a>
  <a href="/tagged/banana"  class="no-underline no-wrap db f3 fw3 black-50">Banana</a>
  ...
</div>
Answered 9 months ago · Improve this answer