Code bài viết lên quan cho Blogspot

Bài viết liên quan giúp người dùng tìm được các bài viết có nội dung liên quan tới nhau (cùng nhãn - label) trong cùng 1 blog.

Bước 1: Vào quản trị -> Mẫu -> Chỉnh sửa HTML

Code bài viết lên quan cho Blogspot
Bước 2: Nhấn Ctrl + F và tìm thẻ </head>

Bước 3: Dán code dưới đây ngay trên </head>

<!--Related Posts Start-->
<!-- remove --><b:if cond='data:blog.pageType == &quot;item&quot;'>
<style type='text/css'>
#related-posts{float:left;width:auto;}
#related-posts a{border-right: 1px dotted #eaeaea;}
#related-posts a:hover{background: #f2f2f2;}
#related-posts h2{margin-top: 10px;background:none;font:18px Oswald;padding:3px;color:#999999; text-transform:uppercase;}
#related-posts .related_img {margin:3px;border:2px solid #f2f2f2;width:98px;height:98px;transition:all 300ms ease-in-out;-webkit-transition:all 300ms ease-in-out;-moz-transition:all 300ms ease-in-out;-o-transition:all 300ms ease-in-out;-ms-transition:all 300ms ease-in-out;}
#related-title {color:#222;text-align:center;padding: 0 10px;font-size:14px Oswald; line-height:16px;text-shadow:0 2px 2px #fff;height:28px;width:98px;}
#related-posts .related_img:hover{border:4px solid #E8E8E8;opacity:.7;filter:alpha(opacity=70);-moz-opacity:.7;-khtml-opacity:.7}</style>
<script src='http://fileitviet360.googlecode.com/svn/relatedposts.js' type='text/javascript'/>
<!-- remove --></b:if>
<!--Related Posts  End-->

Bước 4: Dán code dưới đây dưới <div class='post-footer'>

 <!-- Related Posts Start-->
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<div id='related-posts'>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.isLast != &quot;true&quot;'>
</b:if>
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<script expr:src='&quot;/feeds/posts/default/-/&quot; + data:label.name + &quot;?alt=json-in-script&amp;callback=related_results_labels_thumbs&amp;max-results=5&quot;' type='text/javascript'/></b:if></b:loop>
<script type='text/javascript'>
var currentposturl=&quot;<data:post.url/>&quot;;
var maxresults=5;
var relatedpoststitle=&quot;<b>Bài liên quan</b>&quot;;
removeRelatedDuplicates_thumbs();
printRelatedLabels_thumbs();
</script>
</div><div class='clear'/>
</b:if>
<!-- Related Posts End-->

*** CHÚ Ý
- Giá trị maxresults=5 các bạn tùy thay đổi theo từng theme và nhu cầu cụ thể
- Tùy từng theme <div class='post-footer'> có thể có 1 - 4 đoạn, các bạn thay lần lượt đến khi đạt kết quả như ý.
- Trước khi thay nên sao lưu trước.

Chia sẻ bài viết

1 Response to "Code bài viết lên quan cho Blogspot"

  1. Well, it’s a nice one, I have been looking for. Thanks for sharing such informative stuff.
    Social Media Marketing

    ReplyDelete