HostGator Web Hosting
Saturday, September 5

How to control the number of blog posts in label pages



Blogger defaults to 20 most recent posts are displayed on label pages and provide a link called "Older posts" to
view other posts. To change the number of posts shown on label pages involves editing your template and adding some code which controls the number of posts displayed. It is always good practice to make a full back up of your blog template before making any modifications to the template, so be sure to have done this before implementing this way!

The process is different depending on whether you use a default label list or a label cloud to display your labels, so I will explain each of these separately for you.

control the blog posts pages number | Future Digit The view of computer
Number of posts display
Label List: Decide on the number of posts you would like to be displayed in your label pages, whether this be 5 posts or 50+ (see below for more details about this). And then ensure you have clicked the "Templates" and then click the "Customize" button. You then need to replace every occurrence of this phrase:


data:label.url
With this instead:
data:label.url + "?max-results=n"

Where "n" (you can put here your desire posts number: 5/10/50 etc.) is the number of posts you would like to display on label pages. An easy way to search for all these phrases is to key CTRL+F. You may also like to copy all of the expanded template to Notepad (or your favorite text editor) and change these phrases using the "replace" function instead. Then you would need to paste the modified template over the existing template. Once you've done this, save your template and click on a label to see the change in the number of posts which are displayed.

Label Cloud: On the other hand, to change the number of posts displayed when readers click on an item in your label cloud, find this line in your template:

a.href = lcBlogURL+'/search/label/'+encodeURIComponent(t);
And replace it with this instead:
a.href = lcBlogURL+'/search/label/'+encodeURIComponent(t) +'?max-results=n';

where "n" (you can put here your desire posts number: 5/10/50 etc.) is the number of posts you would like to be shown on labels pages. This section of code will usually appear in the section for the label widget code in your sidebar. Save your template, and then click on an item in your label cloud to see the change in the number of items.

If you would also like the same number of posts to appear when you click on a label link from your post (usually found in the post-footer section), you would also need to replace all occurrences of "data:label.url" as described above.
Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

0 comments:

Post a Comment