Friday, May 14, 2010

How to add facebook like button on each blogspot posts

Facebook social plugin was released. It's easy to add facebook like button on our whole site. But It's little difficult to add facebook like button on our each blog post. So I explain this approach for blogger/blogspot service.

  1. [Layout] -> [Edit HTML]
  2. Turn on the checkbox "Expand widget templates"
  3. Into the tag of class='post-header-line-n' or class='post-footer-line-n', put the snipet like below:
    <fb:like expr:href="data:post.url"/>
    <span id="fb-root"/>
    <script>
      window.fbAsyncInit = function() {
        FB.init({appId: 'your_app_id', status: true, cookie: true, xfbml: true});
      };
      (function() {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
      }());
    </script>

That's OK!

No comments:

Post a Comment