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.

  • http://jonasnordstrom.se Windyjonas

    ok, this seemed like a good plugin, http://wordpress.org/extend/plugins/like/
    But I’m curious, do you really have to use an iframe for this? I hate the way iframes block onload-handlers.

  • http://tdhedengren.com Thord Daniel Hedengren

    There is a javascript solution as well but it requures the Facebook javascript SDK, hence not so quick and dirty anymore. But agreed, it is preferable to the iframe solution.

  • http://jonasnordstrom.se Windyjonas

    ok, this seemed like a good plugin, http://wordpress.org/extend/plugins/like/
    But I'm curious, do you really have to use an iframe for this? I hate the way iframes block onload-handlers.

  • http://tdhedengren.com Thord Daniel Hedengren

    There is a javascript solution as well but it requures the Facebook javascript SDK, hence not so quick and dirty anymore. But agreed, it is preferable to the iframe solution.

  • http://blog.bottomlessinc.com Bottomless

    The WordPress plugin mentioned (http://wordpress.org/extend/plugins/like/) supports both iframe and javascript, depending on your preference.
    iframe is simpler and works out of the box.
    javascript you need to create a facebook app so it’s more for advanced users.

  • http://blog.bottomlessinc.com Bottomless

    The WordPress plugin mentioned (http://wordpress.org/extend/plugins/like/) supports both iframe and javascript, depending on your preference.
    iframe is simpler and works out of the box.
    javascript you need to create a facebook app so it's more for advanced users.

  • http://www.bhandarigroup.in/ SS Pipe Fittings

    It is preferably the iframe solution but, it’s good to share the likes on the facebook accounts very quickly. Thanks for providing the code snippet as it is directly used on the blog. No need to search anywhere.

  • http://www.bhandarigroup.in/ SS Pipe Fittings

    It is preferably the iframe solution but, it's good to share the likes on the facebook accounts very quickly. Thanks for providing the code snippet as it is directly used on the blog. No need to search anywhere.

  • http://www.machwan.in/ Lead Generation

    A good post on the addition of facebook to your blog. I will try it on my blog as it is the easy way to share all your posts on the face book rapidly. Thanks for providing the direct to use code.

  • http://www.machwan.in/ Lead Generation

    A good post on the addition of facebook to your blog. I will try it on my blog as it is the easy way to share all your posts on the face book rapidly. Thanks for providing the direct to use code.

  • http://www.bes.co.uk Plumbing Supplies

    The stainless steel pipe fittings is much recommended than the plastic one. Stainless is more effective than a plastic. In terms of quality, the stainless can survive much heat that coming from the sun, unlike plastic, it can melt, especially when there is a high temperature.

  • http://www.nokiamobilepricesinpakistan.info/ Mobile Prices Pakistan

     valuable post i really thanks you 

  • http://www.examnotes.me/ Exam Notes

     thanks i really add this button but i try many time i lose so i read this now i go and add this thanks