The Problem
Blogger (Blogspot) Label widget allows us to show all labels, or show specific labels. But in some cases, we may want to show all labels except which just has a small amount of posts - such as less than 5. - or show all except some specific labels.
The Solution
We can use JavaScript to hide unwanted labels, but this is kind of inefficient, this logic is better to be implemented in server side. So we should kind of change the implementation of label widget to add a more check.
Go to the dashboard of your blogger, select Template
-> select Edit HTML
. In the Jump to Widget dropdown list, select Label1. This will jump to the definition of Label1. Look at the code, it basically loop and output all labels. All we have to do is to add a condition, so if the label has less than 5 posts, ignore it.
We can also change the code to ignore some labels, based on its name: data:label.name.
The Code
The complete code is like below:
All we have to do is to add a check: data:label.count >= 5 around the loop:
<b:widget id='Label1' locked='false' title='Labels' type='Label'>
<b:includable id='main'>
<b:if cond='data:title'>
<h2>
<data:title/>
</h2>
</b:if>
<div expr:class='"widget-content " + data:display + "-label-widget-content"'>
<b:if cond='data:display == "list"'>
<ul>
<b:loop values='data:labels' var='label'>
<b:if cond='data:label.count >= 5'>
<li>
<b:if cond='data:blog.url == data:label.url'>
<span expr:dir='data:blog.languageDirection'>
<data:label.name/>
</span>
<b:else/>
<a expr:dir='data:blog.languageDirection' expr:href='data:label.url'>
<data:label.name/>
</a>
</b:if>
<b:if cond='data:showFreqNumbers'>
<span dir='ltr'>(<data:label.count/>)</span>
</b:if>
</li>
</b:if>
</b:loop>
</ul>
<b:else/>
<b:loop values='data:labels' var='label'>
<b:if cond='data:label.count >= 5'>
<span expr:class='"label-size label-size-" + data:label.cssSize'>
<b:if cond='data:blog.url == data:label.url'>
<span expr:dir='data:blog.languageDirection'>
<data:label.name/>
</span>
<b:else/>
<a expr:dir='data:blog.languageDirection' expr:href='data:label.url'>
<data:label.name/>
</a>
</b:if>
<b:if cond='data:showFreqNumbers'>
<span class='label-count' dir='ltr'>(<data:label.count/>)</span>
</b:if>
</span>
</b:if>
</b:loop>
</b:if>
<b:include name='quickedit'/>
</div>
</b:includable>
</b:widget>