April 24, 2010

The quick and dirty way to add a Facebook Like button to your WordPress blog

Facebook have opened up its Like functionality, allowing you to Like posts all over the web and hence automatically post your Likings to your Facebook account. Adding this to your WordPress blog is really easy, this code snippet is all you need:

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php the_permalink();?>%2F&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:400px; height:40px;"></iframe>

Put that in your WordPress theme template wherever your want the Like functionality to be shown. This is usually single.php or index.php, depending on theme and setup. It will add an iframe with the Like button, being 400 pixels wide and 40 pixels high. You can hack that yourself with the width and height parameters at the end of the code.

Of course you could hunt down a plugin as well, there are a few, but I can’t vouch for anyone as I haven’t tried them out myself. If you have a recommendation, do speak up in the comments below.

Thoughts? Let @tdh know on Twitter, or find me elsewhere. There is also a newsletter.