A picture of a coder

How to add ‘Facebook LIKE’ button to website content

Facebook introduced more social interactions with their new “Like” or “Recommend” Button. This Facebook button enables the user to interact with a site or page. Additionally share it with his/her friends at their own Facebook profile.

Well, Facebook does made it pretty easy to Implement the “Like” button code on your site. The complexity comes when it is not a single page website. How about a blog Post? This is where you will need this hack to make it work!

This is done by simply adding the following lines on top/bottom of the web page content.

<iframe src=”http://www.facebook.com/plugins/like.php?href=TheContent-url-goes-here&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>

Note – On the above code, make sure to replace the text “TheContent-url-goes-here” with ur content url.

Example -

<iframe src=”http://www.facebook.com/plugins/like.php?href=http://www.iyngaran.info/&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>

Add Facebook “LIKE” button to WordPress Posts

Open up your single.php and look for the_content(). Paste the code you see below… either before or after the_content()

<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>

<?php the_content(); ?>

###Optional Settings:

If you like to show the faces of your friends, change the part “show_faces=false” to “show_faces=true”

If you like to show the label of the button as “Recommend“, change the part of the code “action=like” to “action=recommend”

I hope this will help you to implement the “Like” button on your WordPress Posts! Have fun and drop me a line at twitter or you can click on the “Like” button on the top of this post.