By default, the Labels Widget that can be added into your Blog through Template -> Page Element -> Add a Page Element will have an automatic count of the number of posts bearing that label tag.
If you don't like to see the count, or you want to change the brackets to square brackets or something else, you can edit the template code. Before any change, remember to back up your template. Go to Template -> Edit HTML and save a copy of your existing template by clicking the “Download Full Template” link. Next, check the “Expand Widgets Template” box.
We assume you already have a Labels widget in your Blog. Our task is to locate this widget in the template. If your Labels widget has a title, it is easy. Simply search (using Ctrl-F in most browsers) for the title. Every label widget is assigned an ID such as id='Label1' or id='Label2' and so on. If you don't have a title for your Labels widget, search for these IDs. Another method which we strongly recommend is for you to enter a temporary title into that Labels widget and search for that title. You can always remove the title after you have amended the template.
The part of the template that defines your Labels widget will look like this:-
<b:widget id='Label1' locked='false' title='' type='Label'> <b:includable id='main'> <b:if cond='data:title'> <h2><data:title/></h2> </b:if> <div class='widget-content'> <ul> <b:loop values='data:labels' var='label'> <li> <b:if cond='data:blog.url == data:label.url'> <data:label.name/> <b:else/> <a expr:href='data:label.url'><data:label.name/></a> </b:if> (<data:label.count/>) </li> </b:loop> </ul> |
|---|
If you don't want the number count to appear after the Labels, delete the portion in red.
Should you want a square bracket, change the portion in red to:-
[<data:label.count/>] |
|---|
If you want a hyphen followed by the number, change the red line to:-
-<data:label.count/> |
|---|
Preview the Template. If this is what you want, save the Template and refresh the Blog page.
© Tricks for New Bloggers


7 comments:
Thanks for help with removing the label number count. The code lacks end tags for div, b:includable and b:widget. Otherwise, perfect. :)
Nice of you to mention it Minna, although it is clear that the focus was on amending the portion marked in red. The rest of the code was merely to tell readers where to find it.
For the benefit of other readers, perhaps I should reiterate that the remaining code should not be modified except for the part shown in red.
hi ho bizwhiz... need ur help :D
I added a new label to my posts "#Requested" but every time I want to add this label to some post i need to write it whole "#Requested" Why is that?
Cos for other labels I only need to type first 2-3 letters and it shows it ... help :D
p.s. Mby it has something to do cos i added that maxresults=999 code... but its working for all other labels except this one...
Hi Bizwiz,
I have a related question that hopefully you can answer...
I am looking for a way to use regular search label URL's to also display the label count.
I would like to add a list of certain (not all!) search labels in my sidebar. for example:
http://yourblogurl/search/label/Politics
Is there any way that I can have the number of posts on my blog that match the label "Politics" to show up in that line?
It would be great if you can answer his!!
Thanks in advance,
Jos
worked great! Thanks!
Thanks for the tips, Pal! it's great..
hank you for the incredible amount of know-how you generously share with the rest of the world. I have implemented several of your tips and tricks but find myself stumped by the label count removal as I can't get Blogger to save once I have removed the code. Has something that makes it impossible? I would greatly appreciate your feedback.
I have something to say ...