Home » , » Thêm comment của facebook vào blogspot

Thêm comment của facebook vào blogspot

Thêm comment của facebook vào blogspot

1. Đầu tiên bạn đóng comment của blogger lại bằng cách vào setting => posts and comments,  => chọn comment location => chọn Hide ( xem thêm hình bên dưới )

Thêm comment của facebook vào blogspot

Lưu cài đặt lại.

2. Vào phần Mẫu chọn chỉnh sửa HTML (Edit HTML) => Chèn đoạn code bên dưới vào trước thẻ đóng </head>  : 

<script type='text/javascript'>
//<![CDATA[
var purl= location.href;
var fb_href = purl.substring(0,purl.indexOf(".html")+5);
var fbcm ='<div class="fb-comments" data-href="'+fb_href+'" data-num-posts="5" data-width="660"></div>';
//]]>
</script>

Trong đó:
  • Data-width là độ rộng của comment box.
  • Data-num-posts là số comment được hiển thị (cũng chính là số bài reply trên 1 comment)
  • Data-href là để phân biệt từng comment box, mỗi địa chỉ data-href khác nhau sẽ cho 1 comment box khác nhau. và trong thủ thuật này data-href chính là link của mỗi bài viết

3. Chèn đoạn code bên dưới vào sau thẻ <body> .

<div id='fb-root'/>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = &quot;//connect.facebook.net/en_US/all.js#xfbml=1&quot;;
fjs.parentNode.insertBefore(js, fjs);
}(document, &#39;script&#39;, &#39;facebook-jssdk&#39;));</script>

4. Tìm đoạn code như bên dưới :

<b:include data='post' name='post'/>

5. Chèn ngay sau nó đoạn code bên dưới :

<b:if cond='data:blog.pageType == &quot;item&quot;'>
<script type='text/javascript'>
document.write(fbcm);
</script>
</b:if> 

6. Lưu lại (Save template),  xem kết quả.
Chúc các bạn thành công !

0 nhận xét:

Post a Comment