Reputation: 21
I use a notification bar for my blog which contain a link for latest post. The problem is that I have to update it manually everytime I post something . Is there any method by which blogger will automatically set the url of that link every time I post anything?
Upvotes: 2
Views: 2486
Reputation: 3789
use this script to
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script><div id="recent-posts"><script language="JavaScript">
home_page = "Enter your blog url here";
numposts = 5;
imgr = new Array();showRandomImg = false;boxwidth = 255;cellspacing = 6;borderColor = "#232c35";bgTD = "#000000";thumbwidth = 0;thumbheight = 0;fntsize = 15;acolor = "#666";aBold = true;icon = " ";text = false;showPostDate = false;summaryPost = 0;summaryFontsize = 10;summaryColor = "#666";icon2 = " ";</script><script src="http://24work-new.googlecode.com/svn/trunk/24work-blogspot/recent-posts-t/recent-posts-min-1-ycode.js" type="text/javascript"/></script><link rel="stylesheet" type="text/css" href="http://24work-new.googlecode.com/svn/trunk/24work-blogspot/recent-posts-t/recent-posts-min-3.css" /></div>
It look like this
Upvotes: 0
Reputation: 5651
We can achieve this by using feed and JavaScript for this. The code will look like -
<script>
function recentPostLink(posts){
var link = posts.feed.entry[0].link[4].href;
document.querySelector('.recent').href = link; // The class present on anchor tag
}
</script>
<script src='https://yourblogname.blogspot.com/feeds/posts/summary?alt=json&max-results=1&callback=recentPostLink' />
Upvotes: 1