Saturday, March 4, 2017

How to show list of categories in blogger through javascript

We can easily show the list of categories as a link in blogger using the javascript.

Here are the simple steps for displaying the list of categories in a static new page -

1. Go to your blogger Dashboard.

2. Navigate to the Pages - New Pages - Blank Page.

3. Please copy and paste the below texts to your blank page.

<script type="text/javascript">
function showCategories(json){ //get categories of blog & sort them
var label = json.feed.category;
var lst=[];
for (i=0; i<label.length; i++){
lst[i] = label[i].term ;
}
lst.sort(); //use any sort if you need that

for (i=0; i<lst.length; i++){
var currentPostTitle = lst[i];
var currentPostURL = "http://www.einfoportal.com/search/label/" + lst[i];
currentPostTitle = currentPostTitle.link(currentPostURL);
document.write("<li>");
document.write(currentPostTitle);
document.write("</li>");
}
}
</script>
<ul>
<script src="http://www.einfoportal.com/feeds/posts/summary?alt=json&max-results=0&callback=showCategories"

</script>
</ul>

Here, Please replace www.einfoportal.com with your website name.

Now click on publish button. Your changes are done..

About the Author

Manish Rai

Author & Editor

I am Manish Rai an IT Professional, I started the www.einfoportal.com at the beginning of 2013.My goal is to establish www.einfoportal.com as a information portal that will help every individual(s) to get the information related to their day by day activities and use this information for the good purpose. I love to share my knowledge with the people. Follow me on Facebook | Google+ | Twitter

0 comments:

Post a Comment

 
Copyright © www.einfoportal.com . All Rights Reserved