In a recent post i showed you how to have your blogs labels displayed in a drop down menu.A comment from APF in that post remarked "I'd prefer to see a drop-down that honors the limit (in my case, 1) number of posts per screen I've set for blogger in general".What APF is referring to here is he has set his blog to display one post per page, so on the home page of his blog there will be only one post.Then the Older Posts, Newer Posts links are there for people to navigate through other posts.You can set the number of posts per page on your blog in your settings under formatting.This works fine on the home page and with the older, newer links but when someone clicks a label the limit is not applied, in this post i will show you how to fix that.
So APF wants only 1 post to be shown when someone selects a label, by default all posts will be shown.This is a bit of a mess, you can end up with 20 full posts loading or even crashing if you have large posts with no jump break.On Spice Up Your Blog i have 12 posts per page and i want the same on my labels page here is how it's done.
Take a look at the default link for the label Gadgets here on SUYB, if you click it you will get a big list of posts with that label :
Now in this link i have set it for only 2 posts to be shown with the older, newer links to see more :
The actual number i have applied is 12, the same as the home page which you will see every time you select a label.So lets see how you can set a limit to any number of posts you choose.
Set Fixed Amount Of Posts Displayed On Labels Pages
Step 1. In your Blogger Dashboard click Design > Edit Html > Tick the Expand Widget Templates box.
Step 2. Find the following code in your blogs html - it will be in your template a few times :
(Click Ctrl and F for a search bar to help find the code - More Info)
Step 3. Replace them all with the following code :
expr:href='data:label.url + "?max-results=6"'
Important - Highlighted is the number of posts displayed, it's set as 6.Replace the number 6 with the number of posts you want displayed.
Linking Directly To Labels
So that will set a number of posts to be displayed in the links automatically generated.By automatically generated i mean labels in a labels gadget in your sidebar or above/below your posts.What if you are adding manually adding labels links to a post, menu or elsewhere ?
Simply add ?max-results=6 to the end of the URL, changing 6 to the number you want.
So this :
That's it your labels pages now have a fixed number of posts displayed.