Reputation: 31
I have a webpage with the following opengraph metatags:
<meta property="fb:admins" content="myid" />
<meta property="og:title" content="myurl.com" />
<meta property="og:url" content="http://www.myurl.com/" />
<meta property="og:description" content="My description" />
<meta property="og:type" content="website" />
<meta property="og:image" content="http://www.myurl.com/images/image.jpg"/>
Im trying to get a Facebook Like button for every post using this code:
echo '<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.myurl.com%2Fnews.php%3Fid%3D'.$postid.'&send=false&layout=button_count&width=100&show_faces=false&action=like&colorscheme=light&font=trebuchet+ms&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>';
Obviously every like button use a different $postid value, but when i go to my webpage and like the post number 1, i reload the page and the post 3 and 4 have a new like too. I unlike, and it's the same. Really weird and annoying. It's like the posts where connected without having the same URL. Do you know how can i fix this?
Upvotes: 1
Views: 384
Reputation: 31
I worked around this issue and instead put a Like button inside the details of each post, and that would solve the problem of having lots of Like buttons in the same page linking each other.
In the details page (i use just one news.php), every time the URL is changed (has different id), the og:url argument is changed the same way.
news.php?id=1 has an og:url content="http://www.mysite.com/news.php?id=1"
news.php?id=2 has an og:url content="http://www.mysite.com/news.php?id=2"
and so on...
Also i change the title and description accordingly to each post so when people share it on Facebook, it will have the correct data and not something generic.
If you want several Like buttons on the same page, i wouldn't know how...
Upvotes: 0
Reputation: 96241
By setting og:url
to the base address of your web site, you are telling Facebook that this is the URL you want to be liked.
Make that the URL of the specific post in each case.
Upvotes: 1