Is there a facebook like button for each product?

Asked

Viewed 536 times

1

I would like to put on my site the facebook like button for each product, because by clicking the button the product with your photo and features can appear on the customer’s wall, what I have today is the button that likes the facebook fan page, I couldn’t find any guidance or hint on the subject.

1 answer

5


Yes there is, according to the documentation Facebook like button, exists the attribute data-href where you can set the absolute URL of the page you will like.

HTML5

<div class="fb-like" data-href="http://example.com/produtos/item-2" 
  data-layout="standard" data-action="like" data-show-faces="true" data-share="true">
</div>

XFBML

<html xmlns:fb="http://ogp.me/ns/fb#">
...

<fb:like href="http://example.com/produtos/item-1" layout="standard" action="like" 
 show_faces="true" share="true">
</fb:like>

<fb:like href="http://example.com/produtos/item-2" layout="standard" action="like" 
 show_faces="true" share="true">
</fb:like>

To make the buttons work, add this right after opening the <body> (as suggested by the documentation):

<body>
<div id="fb-root"></div>

<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 = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

<div class="fb-like" data-href="http://example.com/produtos/item-1" data-layout="standard" 
     data-action="like"  data-show-faces="true" data-share="true">
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.