Sunday, September 2, 2007

Show the 10 Recent Posts to your Blog

Previous trick "Add the 10 Recent Posts to your Blog" may not be updated after you
published a new post so now Blogger Tutor offer you another trick to show the 10
recent post, just follow the instruction below.

Step 1:

1. Go to 'Add and Arrange Page Elements' page

2. Click Add a Page Element

3.Choose 'HTML/JavaScript'



Step 2:

Copy the following code to the 'HTML/JavaScript' element and the red highlight code is the number of post you want to display (Default is 10).
Then change the default address(http://yourblogaddress.blogspot.com/) to your blog address.


/* ---( 10 recent post trick begin )--- */
<div class="widget-content">
<div id="newpostsjinyaolin">
<h2>Loading...</h2>
</div>

<script>
function compareentry(a,b){
order= Date.parse(a.published.$t.replace(/^(\d{4})-(\d{2})-(\d{2})T([0-9:]*)([.0-9]*)(.)(.*)$/,
'$1/$2/$3 $4 GMT')) - Date.parse(b.published.$t.replace(/^(\d{4})-(\d{2})-(\d{2})T([0-9:]*)([.0-9]*)(.)(.*)$/,
'$1/$2/$3 $4 GMT'));
return 0-order;

}
function handlePostsjinyaolin(json) {

var temp = '<ul id="Feed001_feedItemListDisplay">';
var postshow=10;
var sortentry=json.feed.entry.sort(compareentry);
for (var i=0, post; post = sortentry[i]; i++) {
if(i>=postshow) break;
var title=post.title.$t;
var link=post.link[0].href;
var authorname=post.author[0].name.$t;
var timestamp=post.published.$t.substr(0,10);
temp += '<li><span class="item-title"><a href="'+link+'">'+ title +'</a>-'+timestamp+'</span></li>';
}
temp+="</ul>";
document.getElementById("newpostsjinyaolin").innerHTML = temp;
}
</script>

<script src="http://yourblogaddress.blogspot.com/feeds/posts/default?alt=json-in-script&callback=handlePostsjinyaolin" type="text/javascript"></script>
</div>
/* ---( 10 recent post trick end )--- */


Done!!

5 comments:

aiMz said...

hi! thank you for this! i just added this widget on my blog. thanks again!

maro^gal said...

thx alot... looking for tis for long..!!

trying on my blog..

Forest Ang said...

hi alot. I hv added to my blog at www.myhealthtalk.blogspot.com
BTW, is it possible to omit the date...i just want the topic without the date.
Thanks

Nitesh Kothari said...

hey the link redirects you to that particular posts comments.. can you set it to the post link...

謝旭宸 said...

西西成人人體
成人人體孰婦少女
束縛少女
77qe成人影院
6655成人影院性愛
6655成人圖片
超碰免費視頻圖片
人人碰免費視頻
性教育短片
同城約炮視頻聊
俏女佳人夫妻視頻秀
色情夫妻群QQ群
夫妻交友的QQ群
人免費在線聊天室
社聊網
寂寞聊天交友網站
台灣免費視訊聊天室
台灣色情視訊聊天
台灣視訊聊天室
韓國視訊聊天室
后宮視訊聊天網
一葉晴語音聊天網視訊聊天
網愛影音視訊聊天室
uthome影音視訊聊天室
傾城玉女免費視訊區
免費視訊區
寂寞聊天室
愛初夜視訊
視訊網愛俱樂部
視訊網愛
台灣的QQ愛真人視訊
正妹視訊聊天室
台灣聊天室視訊主播
真愛寶貝視訊聊天室
武則天視訊聊天室
便宜點的視訊聊天室
免費視訊聊天室破解版
女性開放聊天室
聊天室網站排行
台灣有免費的視訊聊天室
同城免費聊天室
久久同城視頻聊天室
網聊語音視頻聊天室
免費同城聊天室網站
寂寞富婆
免費寂寞聊天室
五色聊天室
日本視頻社區聊天室
日本視頻
日本聊天室網站