Facebook Like Button Plugin

Update: This development of this plugin has been discontinued

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

  • http://matthewstringer.com/ Matthew Stringer

    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!

  • http://www.martinj.net martinj

    Don't know.
    Im not familiar with the other code you are running.

  • http://www.martinj.net martinj

    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.

  • http://www.martinj.net martinj

    Not to my knowledge.

  • http://www.martinj.net martinj

    I have the same problem, investigating the issue.

  • http://www.martinj.net martinj

    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.

  • http://www.moxdom.com Matthew Kettlewell

    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.

  • http://www.martinj.net martinj

    Check this comment about admin http://martinj.net/wordpress-plugins/facebook-l

  • http://www.mongolei.or.at/ Michael

    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

  • http://www.martinj.net martinj

    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.

  • http://www.mongolei.or.at/ Michael

    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

  • http://www.martinj.net martinj

    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/

  • johnconner24

    I have updated to the latest version, still the same problem. No admin link.

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

  • http://www.martinj.net martinj

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

  • johnconner24

    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?

  • http://www.mongolei.or.at/ Michael

    I think I solved part of the puzzle: In order to create the admin page I temporarily added the META tag “<meta property=”og:url” content=”http://www.mongolei.or.at/”/>” 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?

  • johnconner24

    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?

  • http://www.martinj.net martinj

    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.

  • http://brijux.com John Connor

    I found one solution

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

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

    This will create admin links on new pages that you like. (This still doesnt create admin link for the pages you already liked)

  • http://matthewstringer.com/ Matthew Stringer

    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?

  • spooker

    i dont see the URL (“<meta property=”og:url” ….) property in my main homepage with version 1.3.2

  • http://www.martinj.net martinj

    i know, will get out a fix for that sometime later today.

  • spooker

    that's great.Thanks!

  • http://foledisonnj.org Graham

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

  • http://www.mongolei.or.at/ Michael

    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.

  • http://www.martinj.net martinj

    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.

  • http://www.martinj.net martinj

    Thanks for reporting this, submitted 1.3.4 now.

  • Pingback: Facebook “like” button | Manufacturology

  • http://twitter.com/nugge7 Jaime Quintanilla

    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.

  • http://www.martinj.net martinj

    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.

  • http://www.highfxmedia.com Kurt

    Install this code in your theme functions.php file: add_filter('widget_text', 'do_shortcode');

    This will allow shortcodes in a text widget.

  • http://www.mongolei.or.at/ Michael

    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?

  • http://www.martinj.net martinj

    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.

  • http://www.martinj.net martinj

    Thanks for sharing this! 😀

  • 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 http://www.daddyhogwash.com if you would like to take a look. I have version 1.3.4

  • http://www.mongolei.or.at/ Michael Eisenriegler

    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?

  • http://www.drunkenirishpoet.com bill r

    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.

  • http://www.IndustryReview.org Udi

    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

  • http://www.drunkenirishpoet.com bill r

    The same thing happened to me. I don't see any remedy

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

  • http://www.trendmicro.com Mathias Brandstetter

    I found a XSS attack vector in facebook-like-button-plugin.php line 139:

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

    after:
    echo '<meta property=”og:url” content=”http://'.$_SERVER['SERVER_NAME'].htmlspecialchars($_SERVER['REQUEST_URI']).'”/>';

  • http://www.martinj.net martinj

    Im afraid not.

  • http://www.martinj.net martinj

    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.

  • http://www.martinj.net martinj

    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.

  • http://mattersofgrey.com Joey

    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?

  • Pingback: 10 Traffic Building Plugins for WordPress | THE BLOGGERS' BULLETIN

  • http://www.nikemaxsale.com air max shoes

    Thanks for sharing this

  • Pingback: Tutorial Buat Custom Message Facebook Like | blog.ariff

  • http://twitter.com/sandlog sandlog

    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!

  • http://thebudgetsocialite.com/ Trinidad

    I having the came problem! Did you find a fix?