Add a Facebook Like to Your WordPress Blog or Website

by on April 25th, 2010

A fan no more.

The recent f8 conference unveiled new features for Facebook, foremost among them is the change from becoming a “fan” of a page to “liking” a page. This change was allegedly made to encourage more interaction (I can like something and not be a fan of it, right?) and to increase Facebook’s reach across the internet. Now you can “Like” blog posts, webpages and other sites. When you “Like” the page, it is shared to Facebook for all the world to see. Picture delicious bookmarks shared with a large audience.

Facebook Like

Do you LIKE what you see?

This change can help increase traffic to blog posts and website by encouraging readers to quickly share your link with their

hundreds or thousands of friends. To test out this new feature, we’ve added it to our online magazine, The Post SD.com. Take a look and see if you “like” it.

It’s a pretty easy add for your blog or website as well. You can add both a small button inline with your title or a larger button that shows names of people who “liked” it.

To get started, you’ll have to find and be able to edit your single.php. This page renders individual blog post pages. Open it up and look for the_content(). You can paste the following code before the_content() for it to be at the top of the post, or after it if you want it at the bottom. Also be careful that you don’t have the_content() twice or your content will be double posted.

// start of fb like code

<iframe src=”http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light” scrolling=”no” frameborder=”0″ allowTransparency=”true” style=”border:none; overflow:hidden; width:450px; height:60px”></iframe>

// end of fb like code

<?php the_content(); ?>

You can also get a small like button that doesn’t list who has liked it. You can add this after the <div class="p-con">

<!--Start Facebook-->
<div style="float: right; margin-left: 10px;">
<iframe width="65" height="61" src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=button_count&amp;show_faces=false&amp;width=65&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:65px; height:61px"></iframe>
</div>
<!--End Facebook-->

Time to start sharing and liking. Get to it and let us know if you think we should allow “liking” to our blog!

  • http://www.tourvault.com Elton Borbridge

    Good share, great article, very usefull for us¡­thanks.

  • http://www.exclusiveeat.com/Recipes/ Exclusive Eat

    Nice opinion. I found your blog through google while i was researching for web hosting. I will recommend your site to other people and I am sure they hopefully think the same about your writing on this site.

  • http://loutishmerchant125.tumblr.com/ Ashley Ryback

    I love your blog theme can you tell me the name of it or where you downloaded it? thx.