Loading

Friends

Tạo bài viết liên quan nằm bên phải hoặc trái bài đăng.

Chắc bạn đã thấy Blog mình có thêm bài liên quan trong các bài viết.(hình)



Đây là thủ thuật trích từ Mỏ thủ thuật

1. Vào bố cục
2. Vào chỉnh sửa code HTML
3. Chọn mở rộng mẫu tiện ích
4. Chèn đoạn code bên dưới vào trước thẻ đóng </head>





<script src=’http://data.fandung.com/js/rp-posts.js‘ type=’text/javascript’/>

<script type=’text/javascript’>
var maxEntries = 4;
</script>

<style type=’text/css’>
#rp-pre {
float:right;
width:150px;
padding-left:10px;
}

#rp-content {
border:1px solid #bbb;
background:#eee;
}

#rp-title {
text-align: center;
background:#bbb;
font-weight:bold;
color:#F95107;
margin:3px;
padding-bottom:2px;
}

#rp-posts {
position:relative;
left:-20px;
}

#rp-posts a {
background: url(http://farm3.static.flickr.com/2426/3638176588_31366a6822_o.gif) no-repeat left;
padding-left:13px;
}

#rp-posts ul li {
list-style :none;
}
</style>


- Code : var maxEntries = 4; chính là số bài viết mà bạn muốn hiển thị cho 1 nhãn.
- Trong hình minh họa, box hiện thị ở bên phải, nếu bạn muốn nó hiển thị ở bên trái thì sửa code float:right; thành float:left;

5. Tiếp tục di chuyển xuống phía dưới trong code template, tìm đoạn code bên dưới:

<data:post.body/>

6. Thêm đoạn code bên dưới vào trước dòng code vừa tìm được:




<div id=’rp-pre’>
<div id=’rp-content’><div id=’rp-title’>Bài liên quan</div>
<div id=’rp-posts’/></div></div>

<b:loop values=’data:post.labels’ var=’label’>
<script expr:src=’&quot;/feeds/posts/summary/-/&quot; + data:label.name + &quot;?alt=json-in-script&amp;callback=getRandomPosts&amp;max-results=999&quot;’ type=’text/javascript’/>
</b:loop>

</b:if>


7. Save template.

Tiện cóp luôn bài của Hiếu...Có j không hài lòng cho bạn xin lỗi nha...:D, Giữ lại 1 số thủ thuật để khi thay THEME blog còn làm lại.

1 nhận xét:

mình đang làm thử mục này, tks bạn nhe

Đăng nhận xét

Twitter Delicious Facebook Digg Stumbleupon Favorites More