Home » Thủ thuật blog
Tiện ích hiển thị số bài viết và số bài comment
Thứ Tư, 22 tháng 4, 2009
Thủ thuật này có lẽ không mới lạ gì so với blogger, nên mình sẽ không giới thiệu gì nhiều.
Trước tiên thực hiện thủ thuật này thì blog của bạn phải dược kích họat chức năng RSS Feed từ trước.
Hình minh họa:

Sau đây là cách thực hiện:
1. Tạo 1 Widget HMTL/Javascript
2. Dán đọan code bên dưới vào widget, và di chuyển đến nơi muốn hiển thị, save template lại.
Code:
<script style=”text/javascript”>
function numberOfPosts(json) {
document.write(’Total Posts: <b>’ + json.feed.openSearch$totalResults.$t + ‘</b><br>’);
}
function numberOfComments(json) {
document.write(’Total Comments: <b>’ + json.feed.openSearch$totalResults.$t + ‘</b><br>’);
}
</script>
<ul><li><script src=”http://yourblog.blogspot.com/feeds/posts/default?alt=json-in-script&callback=numberOfPosts”></script></li>
<li><script src=”http://yourblog.blogspot.com/feeds/comments/default?alt=json-in-script&callback=numberOfComments”></script></li></ul>
function numberOfPosts(json) {
document.write(’Total Posts: <b>’ + json.feed.openSearch$totalResults.$t + ‘</b><br>’);
}
function numberOfComments(json) {
document.write(’Total Comments: <b>’ + json.feed.openSearch$totalResults.$t + ‘</b><br>’);
}
</script>
<ul><li><script src=”http://yourblog.blogspot.com/feeds/posts/default?alt=json-in-script&callback=numberOfPosts”></script></li>
<li><script src=”http://yourblog.blogspot.com/feeds/comments/default?alt=json-in-script&callback=numberOfComments”></script></li></ul>
Chú ý: thay đổi các code màu đỏ thành nhưng link của bạn. Code màu xanh có thể tùy chỉnh theo ý bạn.
Như vậy đã xong.
Nguồn Blog Solid

- Ngẫu hứng Blogger (2)
- Bạn biết gì về Blogspot, hãy chia sẻ cùng tôi.
- Blogger chính thức add avatar vào comment feed
- Thêm Reactions vào bài viết của blogspot
- Share 3 template bloger đẹp cho anh em
- 12 cách giảm thời gian load trang cho bloger
- Blogger Templates Vector Responsive
- Tạo iFrame YouTube Màu bạc
- Thêm tác giả, quyền Admin cho blogspot
- Hiển thị nhãn (label) phong cách màu tím cực nổi cho blogspot [V3]
- Thêm Google translate - dịch đa ngôn ngữ cho Blogspot
- Cài đặt theo dõi Google analytics cho blogspot
Comments[ 0 ]
Đăng nhận xét