Simple recent posts for blogger

Posted by Andi Syahputra | 10:37 PM
There's so many complex widget out there that provide ability to show the most recent post in your blog. Now I will share you a very simple javascript snippet that show recent post from your blog, sort by label so if you want to get recent post from any label of your blog, you can get it with this script.

You can simply copy paste this script below:

<script type="text/javascript">
function recentpostslist(json) {
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 = "<br>" + "<a href="+ entryUrl + '" target="_blank">' + entryTitle + "</a> </li>";
document.write(item);
}
document.write('</br>');
}
</script>
<script src="http://fun-tutorial.blogspot.com/feeds/posts/summary/-/LabelName?max-results=10&alt=json-in-script&callback=recentpostslist"></script>



Here is the explanation
- paste this script through add gadget - HTML/javascript
- Change fun-tutorial.blogspot.com with your blog URL
- max-results=10, which means the script will fetch 10 post of your most recent post in those label. You can set it more if you want.
- Change LabelName with the label you want to show, case sensitive please.. :D

For additional info, if you want to fetch recent posts without label, change the URL
http://your blog url.blogspot.com/feeds/posts/summary/-/NamaLabel
to
http://your blog url.blogspot.com/feeds/posts/summary

Hope this help.. :D
hi folks, visit my other tutorial blog at Kumpulan tutorial menarik
0 comments