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

7 Responses to “Adding a Facebook Like Button to Your Posts”

  1. Eric Ryan Harrison Says:

    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*

  2. Dave Bonds Says:

    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?

  3. Dave Bonds Says:

    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.

  4. Arnold Says:

    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.

  5. Arnold Says:

    Oops , forgot to add the link – http://openlike.org/

  6. Michael Wales Says:

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

  7. Arnold Says:

    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

Leave a Reply