Facebook share button

14.Sep.2010

Facebook sharing is just getting more and more popular, and it is good to let your visitors share content on your blog using their Facebook profile. Facebook share button is easy to use – as copying this snippet and pasting it into your website.

This way you can customize you Facebook share button by putting custom image in the link. But if you would still like a button from Facebook website, you can use code from Facebook website.

Snippet to use Facebook share button on your WordPress website:

1
2
3
<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>" title="Facebook share button" target="blank">
Share on Facebook
</a>

Snippet to use Facebook share button on your any other website:

1
2
3
<a href="http://www.facebook.com/sharer.php?u=<?php echo $current_url; ?>&t=<?php echo $current_title; ?>" title="Facebook share button" target="blank">
Share on Facebook
</a>

Real life example of Facebook share button:


Facebook icon by: Benjamin Reid.