Create a “Share on Facebook” Button for Your WordPress Blog

A few weeks ago I posted the article Create a “Send to Twitter” button for your WordPress blog, in which you can create a button that will share what you are reading with your followers.

This week I will show you how you can add a “Share on Facebook” button in your WordPress blog to bring in more visitors. This is very simple, just like the Twitter button tutorial.

Open your single post file (single.php) file from your theme directory and insert the following code within the loop:

<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>
&t=< ?php the_title(); ?>" target="_blank">Share on Facebook</a>

To make things more interesting, you can use getTinyUrl() function to send a short URL to Facebook:

< ?php $turl = getTinyUrl(get_permalink($post->ID)); ?>
<a href="http://www.facebook.com/sharer.php?u=<?php echo $turl;?>&t=
< ?php the_title(); ?>" target="_blank">Share on Facebook</a>

That’s it! Now your readers will able to share your posts in their Facebook. This is a great way to boost your site’s traffic!

Source: WPRecipes

Share:
  • Twitter
  • Facebook
  • del.icio.us
  • LinkedIn
  • Technorati
  • Digg
  • NewsVine
  • Mixx
  • Google Bookmarks
  • Yahoo! Buzz
  • Live
  • Print
  • Add to favorites

Back to top ↑

3 comments so far »

  1. Create a “Share on Facebook” Button for Your WordPress Blog … | Drakz Free Online Service wrote on January 22, 2010 @ 4:38 am

    [...] more here: Create a “Share on Facebook” Button for Your WordPress Blog … Share and [...]

  2. baterya wrote on February 22, 2010 @ 2:39 am

    thanks for this wonderful trick..

  3. sima wrote on March 1, 2010 @ 9:13 am

    sweet dude thanks for this

Comment RSS · TrackBack URI


Back to top ↑

Leave a comment

Name: (Required)

E-mail: (Required)

Website:

Comment:


Spam protection:
What is the sum of 6 + 7 ?