Recent Rotating Post Gadget with Excerpt For Blogger

This JavaScript code will display the latest posts of any feed, the difference being that it has two parts which can be used individually or combined. The top of this widget will show a single post along with the title (link), author, date and a brief summary of its content. In addition, this post will rotate automatically within a list whose number of elements will be decided by us. At the bottom, we'll find a full list with recent posts that, on mouse over, will replace the post above, thus breaking the automatic cycle.

Before adding anything, let's see it in action to decide if it does what we want.


recent posts widget for blogger

How to Add Recent Rotating Posts Widget to Blogger

Step 1. Go to "Layout" > click on the "Add a Gadget" link.


Step 2. From the pop-up window, choose the "HTML/JavaScript" gadget


Step 3. Paste this code inside the empty box:
<style>
.gfg-root {
width: 100%;
height : auto;
position : relative;
overflow : hidden;
margin: 0 auto;
text-align : center;
font-size: 12px;
border: 1px solid #DBDBDB;
}
.gfg-title {
font-size: 16px;
font-weight : bold;
color : #6B6B6B;
background:#F3F3F3;
background-repeat: repeat;
line-height : 1.4em;
overflow : hidden;
white-space : nowrap;
padding: 5px;
text-shadow: 0px 2px #fff;
}
.gfg-entry {
background-color: #FFFFFF;
width : 100%;
height : 9.2em;
position : relative;
overflow : hidden;
text-align : left;
margin-top : 3px;
}
.gf-title a {
text-transform: capitalize;
color: #0000ff;
font-size: 14px;
}
.gfg-subtitle {
display: none;
}
.gfg-list {
position : relative;
overflow : hidden;
text-align : left;
}
.gfg-listentry {
line-height : 1.5em;
overflow : hidden;
white-space : nowrap;
text-overflow : ellipsis;
padding-left : 15px;
padding-right : 5px;
}
.gfg-listentry-odd {
background-color : #F3F3F3;
border-bottom : 1px dotted #CCCCCC;
padding: 5px;
}
.gfg-listentry-even {
background-color : #F3F3F3;
border-bottom : 1px dotted #CCCCCC;
padding: 5px;
}
.gfg-listentry-odd a{
color: #595959;
padding: 0 0px 0 10px;
}
.gfg-listentry-even a{
color: #242424;
padding: 0 0px 0 10px;
}
.gfg-listentry-highlight {
background: #FFFFFF;
}
.gfg-listentry-highlight:before {
position: absolute;
left: 0;
content: '\25BA ';
font-size: 14px;
color: #DBDBDB;
}
.gfg-listentry-highlight a {
color: #242424;
}
.gfg-root .gfg-entry .gf-result {
position : relative;
background-color: #ffffff;
width : auto;
height : 100%;
padding-left : 20px;
padding-right : 5px;
}
.gfg-root .gfg-entry .gf-result .gf-title {
font-size: 14px;
line-height : 1.2em;
overflow : hidden;
white-space : nowrap;
text-overflow : ellipsis;
margin-bottom : 2px;
margin-top: 5px;
}
.gfg-root .gfg-entry .gf-result .gf-snippet {
height : 3.8em;
color: #000000;
margin-top : 3px;
}
.clearFloat {
clear : both;}</style>
<script src="http://www.google.com/jsapi" type="text/javascript"></script><script src="http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.js" type="text/javascript"></script>
<script type="text/javascript">
function showGadget() {var feeds = [{title:'List',url:'http://helplogger.blogspot.com/feeds/posts/default?redirect=false&start-index=1&max-results=10'},];
new GFdynamicFeedControl(feeds, 'feedGadget',{title: 'Latest Posts', numResults : 10, displayTime : 5000, hoverTime : 500});} google.load("feeds", "1");
google.setOnLoadCallback(showGadget);
</script>
<div id="feedGadget">Loading...</div>

How to Customize the Recent Rotating Post Gadget

The URL in blue is for the feed. So, the http://helplogger.blogspot.com URL should be replaced with the feed URL of your blog.

Next is start-index=1. This number indicates which post will appear first on the list. By default, it is the latest post published on your blog, so if you want to begin displaying older posts, change the 1 value.

max-results=10 indicates the maximum number of posts that we will be reading from the feed, beginning from the one that we have set up before in the start-index=1. This number always needs to be equal or greater to what we should see later and what it does is to set the number of posts that will be shown in the gadget. The easiest way would be to put 500 in order not to fail, but the higher the number is, the longer this gadget will take to load, so it's better to adjust to what we need to show.

Finally, here are some other script parameters:
  • title: 'Latest Posts', is the widget's title that appears on top.
  • numResults: 10, number of posts that will show in the list.
  • displayTime: 5000, the delay time between posts in the rotator (in milliseconds).
  • hoverTime: 500, minimum time for an item in the list to be displayed at the top.
If you want to hide the list and show only the posts, change this part:
.gfg-list {
position : relative;
overflow : hidden;
text-align : left;
}
To:
.gfg-list {
display:none;
}
If you want to display only the list, change this:
.gfg-entry {
background-color: #FFFFFF;
width : 100%;
height : 9.2em;
position : relative;
overflow : hidden;
text-align : left;
margin-top : 3px;
}
To:
.gfg-entry {
display: none; }

Step 4. Save the gadget and you're done adding the recent rotating post widget with excerpt in Blogger.

9 comments:

  1. Is there perhaps something like the Minimum Comment Length on blogger?
    Love your blog!

    ReplyDelete
  2. Thank you for this. Is there a way to make it show images from the feed?

    ReplyDelete
  3. Thanks a lot guys. this is a good tutorial :)

    ReplyDelete
  4. i just did it, and its saved it, got an error reply.

    ReplyDelete
  5. your blog is very informative.
    i m add css code to my blog customize > Advance > Add CSS to add code now click on apply blog button to apply . view blog code is working.
    when i try to add another CSS code with the same steps but previous code already in the code box, i can't add 2nd code to css , so i m decided to eras the standing code in css box to add new code bcoz previous code is also working. so eras code and past new code and apply blog , when the new / 2nd code is working but the 1st / previous code is deleted and no more working ... Please help me i m upset for that.
    my blog address is .
    www.thaheemsoftware.blogspot.com

    ReplyDelete
  6. how if i want to add the thumbs?

    ReplyDelete
  7. this is a great widget! earlier i was trying your recent post widget but it didn't work, i guess it is outdated or something. but this one works great, it also works anywhere(post, static page)

    if you want to use your feed base on a label instead of recent post, here's a way to do it:

    just change the feed address to:
    [{title:'List',url:'http://your-blog-address/feeds/posts/summary/-/your-label?max-results=100'},]

    ReplyDelete