How To Display Recent Post Titles Under Labels.

Have you fed up by adding your recent posts in different categories/labels manually?
Then I have here a simple solution for you to add your recent posts automatically under different categories or labels. Once only you need to add this to your blog, after the list will automatically update itself.

Just follow the below steps to add this in your blog.

 

  1. Go to Dashboard > Design > Page Elements.
  2. Click Add A Gadget.
  3. Then select HTML/Javascript .
  4. Then enter a label as the title of your widget.
  5. Then paste below code inside the content box.
  6. Save changes

<script type="text/javascript">
function recentpostslist(json) {
document.write('<ul>');
for (var i = 0; i < json.feed.entry.length; i++)
{
for (var j = 0; j < json.feed.entry[i].link.length; j++) {
if (json.feed.entry[i].link[j].rel == 'alternate') {
break;
}
}
var entryUrl = "'" + json.feed.entry[i].link[j].href + "'";//bs
var entryTitle = json.feed.entry[i].title.$t;
var item = "<li>" + "<a href="+ entryUrl + '" target="_blank">' + entryTitle + "</a> </li>
";
document.write(item);
}
document.write('</ul>
');
}
</script>

<script src=”BLOG_ADDRESS/feeds/posts/summary/-/LABEL_Name?max-results=POST_COUNT&amp;alt=json-in-script&amp;callback=recentpostslist”>
</script>
<span style=”float: right; font-size: 80%;”>Get this <a href=”http://learnwebtips.blogspot.com/2012/01/display-post-titles-under-labels.html”>widget</a></span>

Now please do the following changes to the code.

  • Replace BLOG_ADDRESS with your own blog address, example If your blog address is www.learnwebtips.blogspot.com then you would have to replace BLOG_ADDRESS with http://www.learnwebtips.blogspot.com
  • Next change LABEL_NAME   with your labels. Please note, labels are case sensitive.
  • Then change POST_COUNT  with the number of posts you want to display.

If you want to add this type of widgets again in your blog then you don’t need to place all these above codes in your widget.

Just copy the blue coloured code to each of the  widget and save.
So add this super widget to your blog right now and enjoy…

About Shino

Shino, the author of this blog is a 28 year old master graduate in Computer Science, a professional programmer and web developer. TechMagics.com is his humble venture to share whatever he knows and learns about programming,technology and web world.

16 thoughts on “How To Display Recent Post Titles Under Labels.

  1. TechiePorn

    @Deepsansae.com, Hi it will work. Please make sure that you are putting this entire code above other widgets. That means first time you have to put the code including script on one widget. This widget must be at first. After that you have only need to copy past blue colored script only.

    Try again. Best of luck…

Leave a Reply