Have you ever tried to add more than 1 Like button on the same webpage?
If yes, you probably learned that placing more that one Like button on a page can cause some validation erros such as the Duplicate ID fb-root.
Luckily, I have the solution and it is quite simple: all you have to do is to include the Facebook Javascript just once, somewhere in the HTML, inside the body tag
<div id="fb-root"></div>
<script>(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));</script>and place the button code where you want to be displayed:
<div class="fb-like" data-width="150" data-href="<?php the_permalink(); ?>" data-send="true" data-layout="button_count" data-show-faces="false" data-colorscheme="dark"></div>
This is just an example I used for a Wordpress Blog, you can generate your code from the facebook developers platform.
This way you can achieve a valid markup.


0 comments:
Post a Comment