If you use the internet, can read and know about facebook then you no doubt have heard about Facebook “Like” – quite simply an easy way for Facebook users to “Like” web pages like could already do with comments, pictures etc on the Facebook stream.
For a full writeup on all the options, check this great resource on WebMonkey: Adding Facebook Like Buttons To Your Site is Damn Easy
Granted, my site traffic averages about 6 people and 2 small cats per day so I didn’t set out to put Facebook “Like” on my page to give the thousands of people with huge tracts of land, a way to channel my really popular blog pages onto their Facebook streams… Or did I?
Anyway, enough of my banter – here’s your 30 seconds of zen.
Step 1:
In wordpress, edit your single_post.php page or any other page you want the like button to appear on and add the following under the header code and save it.
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: 'your app id', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
Step 2:
Now, add the following line where you want the “Like” feature to show up.
<fb:like href="<?php the_permalink(); ?>" layout="standard"
show-faces="true" width="450" action="like" colorscheme="light" />
Now, if all is lucky and good with the WordPress Gods, you should have the Facebook “Like” functionality on your blog post.
This is of course, very very simple and quick, and if you read the WebMonkey link above, you can learn more about additional meta data to help describe your content to Facebook, Open Graph Protocol in all it’s shiny new glory, and of course the Javascript SDK.
Alright, dinner is ready and I have to go before my wife kills me in under 30 seconds. Enjoy!
-N





