Free Wordpress Blog Setup

How to Add a Live Facebook Share Button to Your WordPress

By Editorial Staff in Tutorials
How to Add a Live Facebook Share Button to Your WordPress

You have probably seen the famous retweet button by tweetmeme on various blogs. We have written a tutorial in the past about how to add a retweet button on your blog. Now fbshare.me introduces a live Facebook share button that keeps count of the link shared on Facebook, and it allows people to share links through this link just like tweetmeme button. In this tutorial, we will show you how to add a facebook share button to your WordPress.

There is a widget that you can download to make the process easy and automated.

For code junkies, and those who do not like to use plugins here is the code you would need to add in your theme file.

<script src="http://widgets.fbshare.me/files/fbshare.js"></script>

This code will most likely be placed in your single.php. Make sure that you use the appropriate styling to make it fit your needs. The code mentioned above is a general code, and it will show a large button with the count, but if you want to know the parameters that you can use, here they are:

  • size – The size of the button: ‘large’ OR ’small’ (if not specified, defaults to ‘large’)
  • url – The URL of the page you want shared on Facebook (if not specified, defaults to that of the page on which the button is displayed)
  • title – The name of the page you want shared on Facebook (if not specified, defaults to that of the page on which the button is displayed)
  • google_analytics – If no awesm_api_key specified, sets whether fbshare.me links have Google Analytics parameters added: true OR false (if not specified, defaults to false)
  • awesm_api_key – For existing awe.sm customers only (if not specified, will use fbshare.me links)

So an advanced code will look like:

<script>var fbShare = {
url: 'http://www.wpbeginner.com',
size: 'small',
google_analytics: 'true'
}</script>
<script src="http://widgets.fbshare.me/files/fbshare.js"></script>

Feel free to customize it to fit your needs. We are planning to add this on our next design update as well.

Free Wordpress Blog Setup

Comments

4 Responses to “How to Add a Live Facebook Share Button to Your WordPress”
  1. FAQPAL says:

    Good idea to make the button similar to Tweetmeme, more bloggers will be more apt to use it.

  2. Few Days back facebook also released an official facebook share count button.. Though if I compare fbshare.me and facebook official button.. My vote will go for fbshare.me one…

  3. Rick says:

    Thanks for this. Offering the facility to share on Facebook should be a good way of generating more traffic for a blog.

Share Your Opinions

Tell us what you're thinking...
and if you want a pic to show with your comment, then get gravatar!

Please make sure that you have read our Comment Policy.

Due to high volume of request from our readers, we are adding this feature that allows you to stay updated with this post's comments without having to participate in the discussion even though we would love your input as always. Don't worry we hate SPAM just as much as you do, so you will never receive any SPAM messages from our site and that's our promise to you.

Subscribe without commenting

Close Bar