I’m working on this page and I use WordPress as my CMS.
On the index.php page where all my posts show up I want to add a Facebook Like button underneath the title to instantly like a post without going to “Read More”.
But when I click “Like” it likes all of my blogposts so all of them get +1. Is there any way to make the code ONLY like the content of that post the button is clicked?
I’m using the following code:
<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_GB/all.js#xfbml=1&appId=266693680020880";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-send="true" data-layout="button_count" data-width="100" data-show-faces="false"></div>
You need to specify
data-href="http://<<your blog url>>"
to like blog instead of page.For e.g.
Such like buttons are just refering to an URL.
If you want the buttons to have individual “likes”, then you’ll need to provide an unique URL for each one of them. (The URL of the post they are refering to.)
You set the URL with the data-href attribute on the
<div class="fb-like" data-href="URL"....>
element.Note that http://example.com and https://example.com is TWO individual sites when it comes to like buttons.
These are close but in wordpress you’ll want to call
in your loop. That should set up the post to be likes.