Lately everytime Facebook has made a change to their site, it has been something annoying and unwanted. I still can’t take the news feed section which allows me to see every friend of mine who friended someone, joined some group like “I have a hairy back,” or endless updates to Farmville.
However once in a while Facebook makes a change that is rather helpful, at least to bloggers and web designers.

Facebook changed all the Join Group or Become a Fan verbage to Like, plain and simple. However what they also did was now allow websites to install a Like button their own site.
What does this mean? Well if you look at the top of this post, you can see a Like button. If you click it than on your Facebook profile it will tell people you like this page.
That means more sharing of your sites pages and more viewing of your fitness website. But installing the like button is where most people get scared.
It means to enter some code, though you could also download one of the many plugins that have came out since Facebook made this change. Thesis users can easily enter a snippet of code into the custom_functions file and don’t have to add another plugin to their arsenal.
If you’re a Thesis user, then go to Thesis -> Custom File Editor -> custom_functions.
Enter the following code:
function facebook_like_button(){if (is_single()){?><iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID));?>&layout=standard&show_faces=false&width=450&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:60px"></iframe><?php}}add_action('thesis_hook_before_post','facebook_like_button');
Its really that easy. Just don’t forget to close your end tag with a ?> group. You can see the location for this button will be before your post, you can also move it to after your post if you want by changing ‘thesis_hook_before_post’ to ‘thesis_hook_after_post’ if you want the like button by your social bookmarking links.
After the above code is up you should have no problems. The above code also enters the like button on single pages only. It can be modified to be on every post even on the homepage, and if you would like to do that, then use the code below instead.
function facebook_like_button(){global $post;?><iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=standard&show_faces=false&width=450&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:60px"></iframe><?php}add_action('thesis_hook_before_post','facebook_like_button');
The difference is in the command of “global post” and “single.” Now you have a Facebook like button for your readers to click on without leaving your site. If you’re not running Thesis, than you should read this: Install Facebook Like Button
Be sure to leave a comment below if this tutorial was easy to follow or if you have any questions.


{ 5 comments… read them below or add one }
Do you know of any plugins that will handle this? For those of us who don’t use the thesis theme
There are numerous Facebook like button plugins out now. I will do some checking and find out which ones will be worth while.
Pretty nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!
Twitter: pulkitkk
How can I do it for my Blog on Wordpress.com? I’ve tried nearly everything. Even uploaded images on different sites and linked them but it doesn’t work properly.
Thanks for the comment Pulkit. I am not extremely familiar with Wordpress.com blogs and I know you can’t use plugins. The one thing I did find is getsociallive.com where you can add like buttons to individual posts it seems.
May be worth a shot. Good luck.
{ 1 trackback }