Facebook Like Button Plugin

So Facebook announced this new like button that everyone can implement on the web. This plugin makes it easy to add this button to your wordpress blog. Here is how Facebook describes it:

The Like button enables users to make connections to your pages and share content back to their friends on Facebook with one click. Since the content is hosted by Facebook, the button can display personalized content whether or not the user has logged into your site. For logged-in Facebook users, the button is personalized to highlight friends who have also liked the page.

If you have questions, comments or feedback please leave a comment on this page.

More info about like button on facebook.

Shortcode syntax

Example
[fb_like_button_standard] – shows the button in standard layout.
[fb_like_button_count] – shows the button in button_count layout.

Example with optional parameters
[fb_like_button_count show_faces="1" action="like" font="arial" iframe_style="margin:10px;"]

Optional parameters:

  • width = numeric, width in pixels
  • height = numeric, height in pixels
  • action = (like / recommend), Verb to display
  • font = (arial / lucida grande / segoe ui / tahoma / trebuchet ms / verdana)
  • colorscheme = (light / dark)
  • iframe_style = custom css style for iframe/xfbml

Screenshots

Example output

Configuration

Frequently Asked Questions

How do I turn off the button on a single post?

Give the post a custom field with the key “facebook_like_button”, and the value “suppress”. You can do this for as many posts as you want. If you remove the custom field, the button will re-appear on that post.

Why doesn’t my like buttons have a comment form?

The comment form doesn’t work when you use the iframe version of the like button. To fix this you have to select XFBML as you output and add a Facebook App ID. Dont forget to set a correct “Connect URL” for your Facebook Application you tend to use.

Why doesn’t the comment form show when I use XFBML?

Make sure you have added a Facebook App ID. If you don’t have one you can create one here. Make sure the “Connect URL” in the Facebook Application Connect Settings has the same url as your wordpress site.

How can I manually position the plugin in my theme ?

You code use the following code.


//display standard button

<?php echo facebook_like_button_plugin_sc_standard($options); ?>

//dissplay button_count button

<?php echo facebook_like_button_plugin_sc_count($options); ?>

$options is an array with same options as the shortcode. If you want to use your defaults just pass an empty array as argument.

How can I add the button as a Widget in the sidebar?

Add the following code to your themes functions.php file:


add_filter('widget_text', 'do_shortcode');

This allows you to add shortcodes in Text Widgets.

Download

facebook-like-button-plugin

Show some love and share

  • I used this plugin on www.unili.com it works well the only problem is it shows likes only the persons recent activity, not the home recent actions.

  • Could you please add a Google Analytic event tracking option to your WP Facebook Like Button plugin? Details of how to implement are over at http://www.websharedesign.com/blog/how-do-i-track-that-little-facebook-like-button-in-google-analytics.html?utm_source=twitter&utm_medium=social&utm_content=twit-20100827&utm_campaign=blog
  • How do I get it to not try to download something to my computer everytime I go on the main page after it's on there?
  • Pawel
    Hi,

    I use it here: http://www.fotomargines.pl/2010/08/18/biblia-fotografa-slubnego-%E2%80%93-kompendium-wiedzy-od-a-do-z-2/ and it os OK
    I try to use at http://www.pawelsuder.pl/hala-ocynowni-arcelormittal and try to put manually before category but nothing happens :( Any idea? :)
  • Pawel
    @martinj, can you help??
  • Green
    Whenever I try to update settings, I get this error.

    Warning: unserialize() expects parameter 1 to be string, array given in /home/username/public_html/wordpress/wp-content/plugins/facebook-like-button-plugin/facebook-like-button-plugin.php on line 205

    Please make a note of it.
  • If you are using wordpress 3.x, this might be your problem. The plugin hasn't been tested with wordpress 3.x yet.
  • Guest
    Hi, I am having a problem I hope you can help me?

    I added the plugin and code as directed but along with my "like" button it says this:
    Warning: Missing argument 1 for facebook_like_button_plugin_sc_count(), called in /home/findusg1/public_html/shakfehlaw.com/wp-content/themes/blurex/index.php on line 36 and defined in /home/findusg1/public_html/shakfehlaw.com/wp-content/plugins/facebook-like-button-plugin/facebook-like-button-plugin.php on line 19

    Can you please help?

    My blog is http://www.ShakfehLaw.com and I am using wordpress.
  • Hi,

    Anyone manage to make this work from the News Feed? I mean the problem that when a frined likes something it is not shown on your News Feed but only in his Activity :(

    I have put the meta properties (title, type, site_name), the iframe version but i cant manage to get it work :( :( Sometimes it appears for a little in the News Feed and suddenly disappear :/ I can't understand..

    Anyone has a sure working solution?
  • Martin
    Hey,

    I love the plugin it is great!

    I just had 2 quick questions.

    1) Does it matter where abouts in functions.php you put: add_filter('widget_text', 'do_shortcode'); ????

    2) Could you please give an example of an embed code with short code in it.



    What can I put in the $options area? what would the shortcode look like inside that container?

    Thank you!

  • This is sort of important to me.
    When I used the plugin it works okay but: it says
    MOOCHYSCHWAG LIKES <url>
    instead of <post title="">
    Can it be configured to post the post title?
    Are corresponding pages being created? I don't see that either.</post></url>
  • This works great.
    The only problem is i can't seem to get the "like" to show up on my recent activity on fb.
    It shows that i like the item on the blog and shows my name and pic - but not on fb. Can anyone help? It shows up on recent activity when Iike other articles on other blogs. Here's my url if that helps

    http://thebudgetsocialite.com/

    thanks!
  • Tried it on your site and it worked for me.
  • thanks for the plugin.

    however i can't seem to get the "like" to show up on my recent activity on fb.
    anything to troubleshoot? it shows that i like the item on the blog and shows my name and pic - but not on fb.

    thanks!
  • I having the came problem! Did you find a fix?
  • i got it to work by using iframe instead of XBML (even though i created an app id it wouldn't show).

    but i now have the issue of it showing a URL instead of the POST title for the item i like.

    where to change that?

    i tried your site and it didn't show on my recent activity when i chose that i liked it.
  • Any chance you'd get more of the object types in the dropdown? You have website and blog, which are fine for the home page, but what about the others for the individual posts?

    Strange how the like button doesn't sync at all with my FB admin page. Am I missing a step?
  • I found a XSS attack vector in facebook-like-button-plugin.php line 139:

    before:
    echo '<meta content="http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'" property="og:url">';

    after:
    echo '<meta content="http://'.$_SERVER['SERVER_NAME'].htmlspecialchars($_SERVER['REQUEST_URI']).'" property="og:url">';
  • AJ
    I'm using the button_count version and it works great, but I was wondering if there was anyway to change the like number to be on the left of the button, instead of the right.
  • Im afraid not.
  • Hi Martin,

    I installed the plugin and it worked perfectly. However, when I upgraded it (Wordpress suggested a new version was out), it reset all the 'likes' I had on the posts. Do you know what this happened? Is there a way to restore this?

    Thanks,
    Udi
  • This is a side effect of getting the admin linking to work correctly. The only way to restore it is to download one of the old versions.
  • The same thing happened to me. I don't see any remedy
  • I have a simple Iframe like written into my page. It showed 50 likes the other day and then yesterday it went down to 0 likes. I could like it again but when my friends like it nothing happens. Is this a glitch with facebook? I would like to keep the Iframe setup because I just want something simple.
  • karlfrankjr
    I installed this on my blog and I thought that it is working, but now it is not. When I click the "Like" button, I see an image briefly and then it fades away and then at the end of the line is a red "error" message that says that the page can not be reached. My blog is www.daddyhogwash.com if you would like to take a look. I have version 1.3.4
  • If Facebook can't reach that URL it will report that type of error. For information about the inner workings of that you have to reside to the facebook developer forums.
  • I've updated to the latest version (1.3.4) but the Like buttons are directed to my website, and not the individual posts. Check it out: http://thelakersnation.com/blog/

    Maybe I'm doing something wrong.
  • I can see the problem on your site but I was unable to reproduce on my. I don't have a clue what the problem is. Have to see if i get more reports on this issue and if I can see a connection.
  • I recently installed version 1.3.3 on my site http://foledisonnj.org

    This morning, I observed that no-one is reported as having liked posts or pages. When I tried to "Like" a page again, I appeared, but if I went to another page, then returned to the original page, my "Like" had disappeared.

    When I tried liking a page, I received an "error" flag. Clicking on it, I saw the following Facebook error message: "You failed to provide a valid list of administators. You need to supply the administors using either a "fb:app_id" meta tag, or using a "fb:admins" meta tag to specify a comma-delimited list of Facebook users."
  • 1.3.3 was broken. I have submitted 1.3.4 now, but you should add either facebook admin or app id property in settings.
  • Thanx for your plugin! I've just managed to get it working using XFBML and also have the comments field. However, it still does not show up as a page. Any hints?

    But one more strange behavior I just found out: Whenever I like an article for the first time (without commenting), the corresponding oneliner in facebook reads: "Michael liked <article>". If I then "unlike" it on my web page and press "Like" again, the new oneliner reads "Michael liked <article> on <webpage>". Do you have any explanation or fix for this?

    Thanx a lot and keep up the good work!

    Michael</webpage></article></article>
  • Have you updated to version 1.3.2?
    Overall the Facebook Like button is generally buggy, there is a lot of bug reports on facebook on all kind of weird behavior about "page creation" "like count" etc.
    Im trying to keep it updated to any solutions i find, but most of the issues is out of my control.

    From what i could see when testing the "page creation" it seems like it has to be on a page that the administrator hasn't liked before, or anyone liked before and required to post a comment as well, but it didn't work 100% of the tries i made.

    The other problem you describe sounds like a problem with facebook and not the plugin itself.
  • Yes, I have updated already.

    What do you exactly mean by "it seems like it has to be on a page that the administrator hasn't liked before"? An individual posting? A static page? Or no "Like" on this website at all? How could I then ever get this admin page? Shall I "unlike" all my "likes" and then post a comment?

    By using XFBML, should I also find this admin page under "Ads and Pages" or under the developer-menu?

    Thanx again,

    Michael
  • The like button is bound to a specific URL, the permalink to the page/post. I had to like a page that hasn't been liked before and post a comment at the same time. But i guess you can add a page manually as well on the link below.

    The Admin page is located at http://www.facebook.com/pages/manage/
  • I think I solved part of the puzzle: In order to create the admin page I temporarily added the META tag "<meta content="http://www.mongolei.or.at/" property="og:url">" to the page header (thus overriding the plugin), apparently because the admin page only appears, if you press "Like" on the base URL and not on an individual article. Unfortunately, when I remove the tag again, I see only myself as a "fan". Is it meant that way, that there is one admin page created for each posting? Or have I still not understood the concept?
  • I didnt get you properly. You mean to say that you have to like the root domain first in order to create admin pages for separate posts?
  • I think i got a solution for this problems, will get a new fix out as soon as i get time for it
    The root page still needs to have the url property even though you don't necessarily have a like button pointing to your domain.
  • I just updated to 1.3.3. with the effect, that I can only "like" the page itself any more, not individual articles. I suspect that it is the "meta property="og:url" content="http://www.mongolei.or.at"/" that is now included in every page. It overrides the individual articles.
  • Thanks for reporting this, submitted 1.3.4 now.
  • I now updated to 1.3.4. The "Like"-Button works again as it should for each individual article, but again, I do not have an "Admin"-Page on facebook. It seems that I can either like the whole site and have an Admin-Page or like individual articles and don't have one. Do you have any solution for this dilemma?
  • The admin page is for the whole "site" e.g it creates a single fan page for your site. When someone likes an article they also becomes a fan to your site and not to a single article. This is working as intended, at least on my setup. However there is still this problem with liking a page that has already been liked before wont be hooked to your admin page, doesn't look like there will be any solution for that problem.
  • I just discovered the next strange bug. If I like the latest article on my blog it just says "Michael likes content" (instead of "Michael likes Kulturen bitten zu Tisch am 27.5."). Interestingly enough this just happens with my Admin account. If I like this page with a different facebook account it works as it should. I also tested it on an older posting, and it worked there with both accounts. Any ideas?
  • Whenever we see someone click Like on a post, it doesn't generate the corresponding Page on Facebook. We've entered in the appropriate admin IDs in the plugin's options page, and I notice that they show in the metadata. So, what could we be missing? Thank you!
  • Made a fix in version 1.3.2, it was missing the proper meta tags on the "root/homepage". I hope this resolves the issue for you.
    However it seems like you need to like a page and submit a comment for it to create a page, but it can only get it to work for pages i haven't liked before.
  • spooker
    i dont see the URL ("<meta ....)="" 1.3.2="" homepage="" in="" main="" my="" property="og:url" version="" with="">
  • i know, will get out a fix for that sometime later today.
  • spooker
    that's great.Thanks!
  • Thanks, man! So, basically, for us to be able to actually be admins we have to use the XFBML version? So, we need to create an application ID for it? Is there a way for this to work without connecting it to a facebook application?
  • I have the same problem, investigating the issue.
  • I've got your plugin working (big thanks too)... but there is interference with the sidebar code from FB to display my FB page updates.... is there something special I need to get FB code and your plugin to play nicely?
  • Don't know.
    Im not familiar with the other code you are running.
  • Turns out that I just needed to grab a new set of code from FB. They changed things from the last time I grabbed a widget from them.... I used the iframe version of things, but they have a FBML version as well that I could have used... thanks for the plugin, it's working great.
  • This is the 4th plugin I tried and it worked beautifully. Thank you! Only trouble is it does not seem to be working in Internet Explorer. Looks great in Firefox, but now showing in IE. Not an issue for me, but for my site visitors using IE. Two different sites - check the "articles" page on both to see what I'm talking about: www.careermoxie.com and www.instanthrsolutions.com
  • I don't use IE nor promote use of it.
    Afaik the plugin is implemented in the way Facebook suggest.
    This is nothing i will try to fix, however if someone should supply me a solution for it i would of course add it.
  • Is it possible to retrieve the number of likes into a custom field in a post?
  • Not to my knowledge.
  • The like button works but I dont see the admin link. I have the correct user ID set but I dont see the admin link. You can check the source code here http://brijux.com

    Also, for one of the post on my blog had 900+ likes after I just installed the like button? How did people liked it even before my page had like button?
  • I have updated to the latest version, still the same problem. No admin link. (I dont see any new meta tag "root/homepage" added in my source code )

    (PS: in the Facebook user ID field, yoiu have mentioned to put "user IDs or usernames of the Facebook accounts". Does this mean that I can use my 'alpha-numerical-user-name' or my 'numerical user ID' ?)

    Also, it will be great if you can make an option to display the Like button on both places, i.e. before AND after the content. (The current option lets you put in either on top OR at the bottom of content)
  • It should be the numerical profile id, dunno why i typed "or username" in the help, will remove that for next release.
    Read this thread http://martinj.net/wordpress-plugins/facebook-like-button/#comment-48940973
    If there is no created page on facebook, my guess is that the admin link won't show, and getting a page created automatically doesn't seem stable.

    Will consider "both" option for next release.
  • I found one solution

    Current meta tag in your plugin is like this
    <meta content="25******" property="fb:admins"><meta content="Brijux" property="og:site_name"><meta content="blog" property="og:type">

    It works if I change it to this
    <meta content="25******" property="fb:admins"><meta content="http://brijux.com/wp-content/uploads/2010/04/brijux-header-3d-red.png" property="og:image"><meta content="Brijux" property="og:site_name"><meta content="Current library system is very inefficient" property="og:title"><meta content="http://brijux.com/2010/05/05/current-library-system-is-very-inefficient/" property="og:url"><meta content="Page Description" property="og:description"><meta content="blog" property="og:type">

    This will create admin links on new pages that you like. (This still doesnt create admin link for the pages you already liked)
  • Also, you said the latest release contains meta tag for "root/homepage". I don't see any new meta tags added for root/homepage in my source code. Am I missing something here?
  • Ben
    hi,

    for some reason..it's working now...many thanks for the plugin..great work..
    however...

    i have 2 post in wordpress which created a fb page...

    http://www.facebook.com/pages/Fastmotoring-Volkswagen-Golf-Mk-7-will-be-reveal-in-late-2012/113822405319612

    so besides the like button, as i am the admin, i able to see a link with "adminpage"

    any idea on this?

    can do u have a solution to assign the 1st image of the post when u share to fb?
  • The image you assign as a thumbnail to a post will be used.
  • Ben
    Hi,

    i got error when "like" my site...somehow only few of the blog post is ok....

    i use your plugin and also the coding from facebook itself..i troubleshoot for 2 days ...still no luck...can you help ?

    please refer my site at

    http://www.fastmotoring.com/index.php/2010/05/audi-r8-v10-in-malaysias-pavillion-kl/
  • The FB admin property you supplied is invalid (kokben) it should be your FB profile id.
  • Ben
    hi i tried my profile id, also the id number...cant

    my profile is http://www.facebook.com/kokben
    is correct isn't it ?
  • Maybe it is just me but for some reason this doesn't seem to work right on my blog.

    Example this page: http://www.petrilopia.net/wordpress/security-and-hacking/warwalking-nokia-n900/ I clicked that recomend/like link and everything seemed to work ok but on that page there still is that "Be the first..." link.
  • Seems to work just fine for me. Though i know several people has reported that the facebook doesn't always report everyone that has liked it, hopefully they will get that fixed soon.
  • For me it still says "Be the first of your friends to recommend this." even that I have liked that once. I have seen my name once there instead of that "Be the first..." text but now I can't see it even that I checked that page with IE and firefox.
    Or do I have to be logged in to facebook before it says more than just "Be the first..."?
  • Facebook hasn't released any details for how this works. But it seems like you wont see any likes until there is a few when not logged in to facebook. And when logged in you will probably see the likes that are from friends in priority to the likes from everyone.
  • OK. I just feel weird to have "Be first" even when somebody has liked/recomended that for all of those who hasn't logged in to FB.
    But I just tested and it seems to be like that what you just said... when I opened new tab and loggind in FB "Be first" disappeared and my name was there and when I logged out from FB it went back to "Be first".
  • I have installed the plugin on my new blog and the like button on my first post added my pic and said 2 other people liked it, but only my pic was showing up, why not the others?

  • Facebook only shows profile pictures of your friends.
  • hi
    I just want to ask you guy if you're having any difficulties with Fx. Fx just won't publish that "Like" to facebook page.
    Fx - remember my link but not sharing
    Opera - wont even remember but also share
    Safari - OK, Chrome - OK

    I also put that facebook script http://developers.facebook.com/docs/reference/javascript/ to my index

    or am I doing something wrong?
  • Hi!

    Thanks for this great plugin!
    Just one little note: As I saw there is no setting to show/hide the button on the search results pages. Maybe you can add this option to a later version (I'm using Version 1.2).

    Cheers,

    Lucas
  • On facebook I'm getting "Kyle likes Meg + Mark on content." I need to the word "content" to be my website name. For some reason it's not pulling it. Any help on this?
  • The meta information that it use is the Post/Page title and Blog Title under General Settings.
  • Kye
    It appears the problem was the SEO plug-in "Headspace2" interfering. Your plug-in is now pulling properly but I had to deactivate the other. Thanks for the quick feedback!
  • Jättebra plugin! Jag undrar bara en sak. Jag har ett inlägg som tre personer har gillat. Men den visar två namn. De tredje namnet byts in lite på random. Borde det inte så sven nilsson and joakim svensson and 1 other likes this.
  • Vågar inte svara på det, du får gräva efter info hos facebook om det.
  • Aight! Thanks :)
  • jeroz
    Hi and thank you for our really great job !!
    I have one question : Can i put your plugin in a widget sidebar ?
    Thanks a lot !
  • Maria
    check this one out. THeyve done it all. http://ilike.mikaviva.tk/
    it runs mainly on facebook like button :D
  • I've added the Facebook Like widget to my Wordpress blog, but it isn't linking me as the Admin on Facebook. Any suggestions?

    chris-moody.com/blog is the site.

    I have chrismoody (username) and the ID that I was given listed as admins.
  • Install this code in your theme functions.php file: add_filter('widget_text', 'do_shortcode');

    This will allow shortcodes in a text widget.
  • Thanks for sharing this! :D
  • Not at this time.
  • chrissiwake
    This is a great plugin enabling more links between social media accounts. Thanks for sharing, going to try and implement now.
  • DJSD
    Thank You for Your Hard Work! It is Great!
  • How come you're not using your own plugin? ;)
  • I do, look right above "share some love and share" on this page.
  • Oops - sorry. my bad.
  • Thanks for sharing this! I found it to be very helpful!
  • Excellent plugin, live all over http://bravocharlie.tv and I've got people sharing the activism stuff, the music stuff (check out Jame Forbes if you like acoustic guitar, I swear he is going to be a star soon) and the business stuff within minutes of it going in.

    Simple setup, excellent work. Thank you. - Phil, Melbourne
  • Hi,

    Thanks for a plugin, I have a strange problem when I choose "button_count" style - two of my friends liked one of my posts but plugin still shows only "0" instead of "2" or "3"
  • Maybe the data you received from facebook was cached. Try clear cache or restart your browser.
  • Unfortunately it doesn't work, please take a look: http://lukaszmacheta.com, my friends liked first two posts, but all I see is "0" ;/

    Thanks for your reply
  • Working on it.
    There are several reports of this problem from people using the like button not just my plugin. Trying to figure out if facebook is to blame or if I can do something to fix it.
  • Sounds great! Take care
  • Jon
    Additionally, is it possible to receive e-mail notification when someone "likes" something of yours.

    thanks again
  • Nix
    Try a site like this (although this one is in hungarian):

    http://tetszik.org/?s=martinj.net

    Use the upper search form with your domain for searching.
  • Jon
    is there any way to make the font that reads

    "be the first of your friends...." or after its been liked "likes this"
    appear as white as opposed to black...if so how...im sorry..im a newbie programmer

    its because the backdrop of my blog is black so the letters get lost

    thanks so much

    great pluging!
  • It just crossed my mind that if you change the Color Scheme to dark the text will be visible on black background :)
  • It might be possible to do some extra styling by using classname that facebook supplies. This isn't anything that I would include in the plugin unless facebook add a specific option for it.
  • Great plug-in. Very useful... To improve it against all the other clones out there: How about a feature to suppress it a page-by-page basis?... I suggest to mimic the Topsy.com technique: Using a custom-field (i.e. "facebook_like") and the value "suppress" on those pages/posts where is not needed)
  • Sounds like a great suggestion. Will take a look on that.
blog comments powered by Disqus