Thursday 27 March 2008

Change numbers of posts displayed by label

Blogspot already has UI allow our to set the number of posts displayed at main page or displayed by days.


Check this picture below :



But when we click on a label in Label widget, there're many posts displayed.
By default with a blogspot blog, max of posts displayed is 20.
And you need to customize number of posts display by label, do the following :



Go to "Edit HTML" as in picture above. Remember to save your template ( for safety ;) ), and then check the check box "Expand Widget Templates".

Now, press Ctrl+F and find below snippet:


<div class="post-footer-line post-footer-line-2">
<span class="post-labels">
<b:if cond="data:post.labels">
<data:postlabelslabel>
<b:loop values="data:post.labels" var="label">
<a href="data:label.url" rel="tag"><data:label.name></data:label.name></a>
<b:if cond="data:label.isLast != "true"">,</b:if>
</b:loop>
</data:postlabelslabel>
</b:if></span>
</div>


The snippet above show post's label at (usually) bottom of your post.
Notice the phrase in RED, modify it to customize your posts number displayed:
<a expr:href='data:label.url + "?max-results=3" '
3 is mine, just replace yours.

And, the snippet below is the Label widget:

<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>

Change phrase in RED and we done:
expr:href='data:label.url + "?max-results=3" '
Now, test your work and enjoy.
Happy harvest exp.
Moongy

7 comments:

luzonsavana said...

huhu.. thats a great knowledge...


http://insurance-transport.blogspot.com

Anonymous said...

try using your comments by Name/URL ( choice 3 ) to promote your link, or put under a hyperlink

like this

http://xpsharing.blogspot.com

Anonymous said...

hello!
This was nice, I wonder if you know how to change the number of labels displayed once you clicked on them. I have a lot of images and I only display 3 in the main post. how do i only display 3 post once clicked on label?

any idea? thanks

Growyourblog said...

hello mr likeable,
i wonder what's you mean? my post also contains guide for 'only display 3 post once clicked on label'.
let me know if it didnt work for you :)

Anonymous said...

I do not know what I did wrong. I must have read it wrong but this time I tried again. It perfectly worked. Thanks for replying so fast, had to try again to verify that It was nothing wrong with what I did but It ended up being. thanks a a lot. Great site. simple and fast page load

Joomla developer said...

Great work.Nicely presented information in this post, I prefer to read this kind of stuff.Please create more blog and i
need more related to seo.Thank u.

Free Hollywood Movies said...

Thanks for providing most useful information.

http://a2zhollywoodmovies.blogspot.com/