How to list recent post titles by label
Once added, the list will update itself automatically. The widget takes your blog’s label-specific feed, in JSON format and turn it into a list using Javascript. It other words it does the listing for you.
No more slow and tedious manual updating and rearranging. Sounds good? Here we go:
No more slow and tedious manual updating and rearranging. Sounds good? Here we go:
1. Installing the first list
- Go to Layout
Design>>Page Elements. - Click Add A Gadget.
- In Add A Gadget window, select HTML/Javascript .
- Enter a label as the title of your widget.
- Copy the code below and paste it inside the content box.
- Click Save.
<!-- Recent Posts by Label Start --> <!-- code by / --> <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="YOUR_BLOG_URL/feeds/posts/summary/-/YOUR_LABEL?max-results=SHOW_HOW_MANY&alt=json-in-script&callback=recentpostslist"></script> <span style="font-size: 80%; float:right;">Get this? <a href=" /">widget</a></span> <!-- Recent Posts by / Label End -->
- Replace
YOUR_LABEL
with the label. Labels are case sensitive, make sure you get it right. - Replace the value of
SHOW_HOW_MANY
with the number of posts you want to display. To show all posts, use 500 (I believe 500 is the maximum. If you have more than 500 posts under a certain label, do leave a comment, we’ll work something out). - The titles are bulleted due the use of ordered list
<ul>
. If you want them numbered instead, just replaceul
(in line 5 and 18) withol
.
0 Response to "How To List Recent Post Titles By Label"