Adam Lynch
Adam Lynch

Reputation: 3369

Facebook "like" button which likes another page/URL

I have a list of links and on each individual page there's a "like" button to "like" that page. But I want a "like" button next to each link in the list which will like the URL of the link next to it (just like it would if you clicked on the link and then the "like" button).

How do I do this?

To create the button on each individual page I use the following code:

<script>
window.fbAsyncInit = function()
{
     FB.init({appId: '*****', status: true, cookie: true, xfbml: true});
};
</script>

<div class="share_button btn_fb">
<fb:like layout="button_count" font="tahoma"></fb:like>
</div>

Upvotes: 3

Views: 7006

Answers (4)

Kenny Cason
Kenny Cason

Reputation: 12328

You can always just go to the Facebook Developers page here:

http://developers.facebook.com/docs/reference/plugins/like/

and it will generate the code for you, and you can just copy it into your site. I just re-verified it. It works nicely.

This will generate the code(or something similar) that @Coding-Freak wrote.

Upvotes: 1

Sujit Agarwal
Sujit Agarwal

Reputation: 12508

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="[put the url here]" send="true" width="450" show_faces="true" font=""></fb:like>

Just replace the [put the url here] with the url you want to like and then paste the full code to the place where you want the like button.

Upvotes: 1

bsimic
bsimic

Reputation: 926

Try the following:

<fb:like layout="button_count" href="http://yourlink.com" font="tahoma"></fb:like>

Where the href attribute is the URL you want the person to 'like'

Upvotes: 5

Connell
Connell

Reputation: 14421

You can use the iframe version of the Like Button, rather than FBML. The iframe requires that you pass the url as part of the query string.

You can generate the iframe code here.

Upvotes: 6

Related Questions