Skip to content

Add a Facebook Like Button to Your Site in 2 Minutes

4 Sep 201017 comments Code, Social Media, Video Tutorials, Wordpress

Adding the Facebook Like Button anywhere on your WordPress site is incredibly easy

Adding the Facebook Like Button anywhere on your WordPress site is incredibly easy

Facebook, as the king of all social media sites with over half a billion users should be one of your primary focuses for your social media strategy, particularly if your site is of ‘general interest’.

Recently, Facebook enabled anyone to add a little bit of code to their site to enable the “Like” feature on their site, which allows friends to quickly tell everyone about your site and also for users to see if any of their friends like the page their on. It’s a very social way of spreading word around about your site.

Adding the code

First, you need to decide where to put the button – it might be before your content, after it, or perhaps in the header or footer. If you want it before or after your content, you’ll need to place the code in single.php and if you want it in your header or footer, you’ll need to put it in header.php or footer.php respectively.

Once you’ve opened up the file for editing, just insert the following code where you want the button to appear:

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&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:450px; height:60px;"></iframe>

Now you also have a few configuration options that you should be aware of. Change the following values to customise your button:

layout=button_count

This will just show the button and the counter, as opposed to adding text next to the button showing who else you know likes it

show_faces=true

Will add the friends icon underneath the button.

action=recommend

Change the wording from Like to Recommend

color_scheme=dark

This might better suit your color scheme.

Did you give it a go? Did you come across any problems?

Related posts:

  1. Post your Facebook Status Updates to Twitter automatically
  2. What is the Loop?
  3. 10 WordPress plugins that every website needs… and others that may come in handy
  4. How To Display Code Within A WordPress Post
  5. Using Anchors in WordPress
OIOpublisher

About the Author

Dave Clements designs awesome websites and offers WordPress consulting services in his spare time, along with eating Wheat Thins, spending time with friends and family, watching Indie films and playing with his array of Apple products.

Like it? Share it!

Comments

  1. noaspa September 5, 2010

    Thanks Dave – just did it
    Best wishes
    Will
    ( another wanderer – now in Hamburg)
    My recent post Noaspa News – 01092010

    • daclements September 5, 2010

      And how did it work for you? it looks like your main site is a blogspot site and it probably won\’t work there

  2. noaspa September 5, 2010

    Hi Dave,

    I put it in the sidebar & it seems fine
    ( it worked when I "liked" the site).
    Maybe you could test it too? ;—-)

    Cheers
    Will
    My recent post Noaspa News – 01092010

    • daclements September 5, 2010

      So it does, that\’s interesting. I guess blogspot uses the same tags as WordPress. Thanks for folioing up!

  3. Sathish Kumar September 6, 2010

    I am using Thesis and Its more easier for me to add this code with a hook. Thanks for sharing.
    My recent post Thesis 18- Features and Review of Thesis 18 WordPress Theme

    • daclements September 6, 2010

      Ahhh, I've not got round to using hooks yet. That's one of the next things on my learning list I suppose ;)

  4. Ileane September 7, 2010

    Hey Dave, nice screencast. What are you using to create them? I use Screenr and Screencast-o-matic. Thanks for the tip and the code.
    My recent post How-to Customize Your Amplify Page

    • daclements September 7, 2010

      Hi Ileane – nice to meet you. I've seen your name floating around quite a bit, so it's good to see you here. I personally use IShowU HD for recording my screencasts. I wasn't sure about screencast-o-matic and had never heard of Screenr, but IShowU is a nice piece of software.

      Take care
      My recent post Add a Facebook Like Button to Your Site in 2 Minutes

  5. California DUI September 10, 2010

    I have read last week an article about the scam using the like button on facebook wherein it has been stated that before you put some features to your facebook account, you need to make sure if it is scam or not because there are people that are using this just to have also an easy access to your account which only means that your account is not already secure. it can easily access by those scammers. Who do you think should i prefer to believe?
    My recent post ROR Sitemap for http-wwwcaliforniaduihelpcom-

    • daclements September 10, 2010

      Well clearly you have to exercise caution when allowing apps access to your profile. However, aside from ShareThis being very reputable, they also do not need to connect to your Facebook account, so there are no security risks

  6. Alexandra October 18, 2010

    Please, can you help with installing both facebook and twitter button just the way you have it on the top of your pages. Question is how to make it like that.

    • Dave October 18, 2010

      Yes, I actually covered this in a recent post: Facebook & Twitter Buttons Without Plugins. Hope this helps!

      • Alexandra October 18, 2010

        Thanks! I did it, but with plugins though. :)

        • Dave October 18, 2010

          Well, glad you got figured out at any rate. What plugin did you use out of interest?

          • Alexandra October 18, 2010

            “ShareThis” plugin. But I’m having some issues with updates in number of tweets and “likes” I had before installation of this plugin.

  7. mlwebdesign January 27, 2011

    Thats cool..i was looking for facebook plugins for my website…Thanx for share Dave…

    • Dave Clements January 28, 2011

      Were you able to get is installed without too much trouble?

Add a Comment

Name - Required

Email - Required

Website - Optional

CommentLuv badge