Home Blogger Templates Blogger Trick – Using JSON APIs With Blogger to Include a Recent...

Blogger Trick – Using JSON APIs With Blogger to Include a Recent Posts Widget With Your Template


My wife changed into designing a blogger template, and she desired to consist of a segment for recent posts. There are plenty of Google widget code sections available for download on the Internet that permit a Blogger consumer to add a Recent Posts phase to a weblog. However, the subject matter for the Blogger template required the feature to be protected as an indispensable part of the template in preference to being elective. I’ll display you ways we executed the project.Vinzite

SimpleTrick-1.gif (1200×675)

Blogger mechanically generates an XML news feed for your blog. The feed lets in human beings to subscribe to your blog so they may receive notices when you submit new posts. This routinely generated news feed is positioned at myblogname.Blogspot.Com/feeds/posts/default. For your unique weblog, substitute your real Blogger sub-domain in the region of my blog name. If you input your BlogSpot URL followed through /feeds/posts/default into a browser, you may see the feed in your weblog for your browser window.

Accessing the feed
Accessing your blog’s feed is achieved by means of the use of a technology called JSON (JavaScript Object Notation) through a callback. I’ll provide an explanation for what I suggest by that. You want to do two matters: 1) create a JavaScript function to technique the feed statistics; 2)Access the feed records and initiate the callback manner by the use of a few question parameters. Here are the technical details.

Inside the blogger template, I positioned a piece of JavaScript code (which I borrowed from one of the widely to be had widgets I noted earlier) within the section of my spouse’s template the usage of the Blogger template editor, that is accessed from a Blogger account with the aid of going to Layout -> Edit HTML. The script basically accesses the feed via the JSON parameter, parses out the weblog titles for the closing mum posts (this variable is exact within the callback mechanism explained later) weblog entries, and writes them out to the net file (as links to actual weblog posts) at the factor from which the feature is referred to as. Here’s the function:


This block of code first sets a few JavaScript variables so that they are to be had while our show recent posts feature is later known as. You’ll note that mom posts are amongst those variables indexed. Mum posts determine what number of latest posts can be displayed.
The script block following the variables tells Blogger to access the information feed for the current weblog (/feeds/posts/default), order the feed entries through the date they were posted (order by-posted), installation a JSON callback (alt=json-in-script), and call our characteristic to procedure the feeds (callback=showrecentposts). The critical query parameters to be aware within the method of the usage of a JSON callback are 1) alt=json-in-script, which tells Blogger we need to access the feed with a JavaScript feature; and 2) callback=showrecentposts, which tells Blogger to name our show recent posts characteristic. It’s important to notice that the name we use inside the query parameter ought to suit the call of our feature.


Indeed choosing the great blogging platform can be pretty taxing for internet website online owners. With the form of alternatives round, every so often making the right preference isn’t always that clean to do. Each has its execs and cons, such that choosing one which works properly for your website is the maximum practical element to do.

The most famous picks for running a blog these days are WordPress and Blogger. There are some web masters who decide upon WordPress, and there are people who decide on Blogger. So, which one is the ideal preference then?

There is practically a struggle taking place within the blogosphere. An average newbie is confronted with too many alternatives to pick from. In order to select the most suitable platform though, it is crucial to take a look at every platform side with the aid of facet and see which one you absolutely desire. Setting up a comparison scale let you out in determining the maximum appropriate blogging platform.

Between WordPress and Blogger, you have to decide which one gives ease of set-up and use customization and advanced use, and copyrights and possession content material among others.

Setting up a Blogger account can genuinely be achieved in 10 minutes. As quickly as you’re completed with the set-up, you can right now begin posting. Moreover, if you want a dressmaker’s contact on your weblog, tons of blogger templates are available free of charge. On the other hand, installing WordPress may be a headache in case you don’t clearly know what you are doing. You want to download the setup files, add them to your server, set up a database, and run the configuration script yourself since you want to host WordPress to your personal account. However, in case you use cPanel, you can without a doubt do the set up with simply one-click on of the mouse.

Publishing with Blogger can be a little inconvenient. Blogger doesn’t allow categories such which you can not type your articles into one of a kind focuses. Posting articles with Blogger can take all the time maximum specifically if there are a few changes that you are going to make on the net website. With WordPress though, you may without difficulty add categories and show each category in a different way for your fundamental web page. With WordPress, publishing is tons quicker and extra convenient.

Finally, with regard to copyrights and possession of content material, Blogger can be quite frustrating. With Blogger, Google definitely owns your content. This approach that Google has the authority to shut down your account if they do not like what you’re blogging about. Unfortunately, they do that with out warning in any respect. In other words, you don’t have absolute control over your very own blog. On the alternative hand, with WordPress, you personal your very own area name. Since the blog is hosted for your account, you have got full control over your web site. As such, you’re loose to write down about whatever and use the software program in any manner you want.