Adding a Facebook Like Button to Your Posts
April 21st, 2010
Facebook just announced their Facebook Social Plugins, a collection on one-liner tools that allows your users to engage and promote your content using Facebook. One of these “plugins” is the infamous Facebook Like button – which I have added to every post within this blog.
Below is the code I used, which is placed within the post loop. Most of this is the standard code you get directly from Facebook, the relevant portion to look at is the urlencode(the_permalink()) bit as well as some of the styling (which will differ based on your own theme).


April 21st, 2010 at 3:39 pm
I already was using SexyBookmarks plugin for this sort of thing, but I really liked the Facebook like integration mechanism. But, since SexyBookmarks was acting as a WP filter on the_content() I had to go in and add this code to the plugin source code.
*sigh*
April 21st, 2010 at 10:27 pm
Awesome discovery Michael! You’re quick.
I don’t see how this connects back to Facebook though.. shouldn’t it publish something on my wall?
April 21st, 2010 at 10:52 pm
Nevermind. Was a little hasty. Apparently it does.
Have you seen Posterous’ implementation, click like, then a hover brings up a “Comment and post on wall…” Thought that was cool.
April 23rd, 2010 at 11:07 am
Found this simple open source JS library that adds FaceBook’s “like” button, among some other popular social networks. One line of JS code and you’re set.
April 23rd, 2010 at 11:08 am
Oops , forgot to add the link – http://openlike.org/
April 23rd, 2010 at 11:35 am
@Arnold
All that does is add a link with an image. It includes none of the functionality of Facebook’s Social Plugins (for example, telling you who (within your network of friends) likes a particular piece of content. OpenLike isn’t anything special – there are literally thousands of WordPress plugins that do this exact same thing – plus, they are using Facebook’s copyrighted imagery. I don’t expect it to last for very long…
April 23rd, 2010 at 3:57 pm
I didn’t have time to check the whole library, but Facebook related code seems to be adding iframe code very similar to what you posted – http://code.google.com/p/openlike/source/browse/trunk/v1/openlike.dev.js#148