Chủ Nhật, 25 tháng 8, 2013

tạo menu ngoài blog theo nhãn

<!-- Recent Posts by Label Start -->
<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="http://yourname.blogspot.com/feeds/posts/summary/-/Label name?max-results=postnumber&alt=json-in-script&callback=recentpostslist"></script>
<!-- Recent Posts by Label End -->


4. Thay thế yourname bằng tên địa chỉ Blogger của bạn. 
Thay Label name bằng tên nhãn cần hiển thị những bài viết mới nhất. 
Thay Postnumber bằng số bài viết cần hiển thị, ví dụ: 5, 7, 10, … Nếu muốn hiển thị tất cả bài viết thì để là 500 (số tối đa cho widget này).

Chú ý: Tiêu đề các bài viết được liệt kê có dấu chấm đầu dòng (dùng thẻ <ul>). Nếu bạn muốn được liệt kê theo số thứ tự thì thay đoạn document.write('</ul>'); bằng document.write('</ol>');

Không có nhận xét nào:

Đăng nhận xét

Join the team! By Submitting your email address: