Show top labels or labels having more posts at label widget

by Deineshd on June 14, 2008

Share


You may have used maximum labels at your blog posts . showing all the labels at label widget may make your label widget look dirty . There is a solution or a hack to show limited labels at label widget by betabloggerfordummies. By using this hack you can show labels having more posts as you define . For example if you define “5″ then the labels having more than 5 posts will be displayed.

Hack starts:

Step 1

First of all sign in to your blogger Account after that goto Layout Page.Now add label widget in your blog (Add a Page Element –> Labels –> Save).If you already have label widget in your blog then you should not have to do this step.

Step 2

Goto Edit HTML section , Expand Widget Templates and Search for the following Code.

<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 class='widget-content'><ul><b:loop values='data:labels' var='label'><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><span dir='ltr'>(<data:label.count/>)</span></li></b:loop></ul>

<b:include name='quickedit'/></div></b:includable></b:widget>

Step 3

Replace the above code with the following code.

<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><ul><script type='text/javascript'>var labelnum = 0;<b:loop values='data:labels' var='label'>if (<data:label.count/> &gt; 2) {   document.write(&quot;<li><a expr:href='data:label.url +  "?max-results=100"'rel='nofollow'><span><data:label.name/></span></a>(<data:label.count/>)</li>&quot;);}</b:loop></script></ul><b:include name='quickedit'/></b:includable></b:widget>

The code above will only show labels with more than two posts. To increase number of labels increase the number two in this code :

if (<data:label.count/> &gt; 2) {

Consider to Subscribe to our RSS feed or Follow us at Twitter or Join our Facebook Fan Page.Enter your Email below to subscribe to our updates via Email.

Enter your email address:

Delivered by FeedBurner

Similar Posts

Powered by Thesis

Thesis Theme

An amazing WordPress Theme, nothing beats the versatility and SEO friendliness of the Thesis framework.

From beginners, to the most advanced WordPress developers, Thesis makes it easy for anyone to customize it.

{ 2 comments… read them below or add one }

Ijas M August 9, 2009 at 5:13 am

Thanx
its working good

Reply

shafi_4u August 28, 2009 at 11:02 am

Leave a Comment

Previous post:

Next post: