UPDATE 2013-11-15: This plugin’s development has moved to my company, Webdados. Any information on this page may be outdated. Please go to: the Facebook Open Graph Tags for WordPress plugin page.


For personal use I’ve made a WordPress Plugin to include Facebook Open Graph Tags on the website/blog headers.

If you find this plugin useful and want to make a contribution towards future development please consider making a small, or big ;-), donation by clicking one of the following links: Donate in Euros | Donate in US Dollars

It also allows to insert the “enclosure” and “media:content” tags to the RSS feeds, so that apps like RSS Graffiti and twitterfeed post the image to Facebook correctly.

There are quite a few plugins that do exactly this already, but each and everyone of the ones I tested lacked something that I needed, so I decided to write this very simple plugin that allows you to decide which tags are included and may be useful to complement other plugins that you may be using to insert Facebook Open Graph tags to your website.

WordPress Plugin: Simple Facebook Open Graph Tags

The inserted tags are:

  • fb:app_id: From settings on the options screen.
  • fb:admins: From settings on the options screen.
  • og:locale: From WordPress locale or chosen by the user.
  • og:site_name: From blog title.
  • og:title: From post/page/archive/tag/… title.
  • og:url: From the post/page permalink.
  • og:type: “website”or “blog” for the homepage and “article” for all the others.
  • og:description : From post/page excerpt if it exist, or from post/page content. From category/tag description on it’s pages, if it exist. From tagline, or custom text, on all the others.
  • og:image: From post/page featured/thumbnail image, or if it doesn’t exist from the first image in the post content, or if it doesn’t exist from the first image on that post’s media gallery, or if it doesn’t exist from the default image chosen on the options menu.

Download the plugin at http://wordpress.org/extend/plugins/wonderm00ns-simple-facebook-open-graph-tags/

The plugin forum on WordPress.org: http://wordpress.org/tags/wonderm00ns-simple-facebook-open-graph-tags?forum_id=10

Changelog:

  • 0.4.1 (2012-12-21)
    • Added the ability to set/replace the Canonical URL tag. Very important for SEO in the “Business Directory Plugin” integration.
  • 0.4 (2012-12-21)
    • “Business Directory Plugin” plugin integration. It’s now possible to populate “og:title”, “og:url”, “og:description” and “og:image” tags with each listing details. If a featured image is set it will be used. If not, the listing main image is used.
  • 0.3.4 (2012-12-10)
    • Fixed a bug where all the settings could be lost when saving other plugins options (Shame on me!!)
  • 0.3.3 (2012-10-15)
    • Fixed a bug where unset options would become active again. Thanks to @scrumpit.
  • 0.3.2 (2012-10-01)
    • Fixed a typo on the settings page
  • 0.3.1 (2012-10-01)
    • When saving the settings the $_POST array was showned for debug/development reasons. This output has been removed.
  • 0.3 (2012-10-01)
    • “SubHeading” plugin integration. It’s now possible add this field to the “og:title” tag.
    • Changed the way defaults and user settings are loaded and saved, to “try” to eliminate the problem some users experienced where the user settings would disappear.
    • Bugfix: “Also add image to RSS/RSS2 feeds?” option was not being correctly loaded
    • The plugin version is now showed both as a comment before the open graph tags and on the settings page
  • 0.2.3 (2012-09-26)
    • No changes. Had a problem updating to 0.2.2 on the WordPress website.
  • 0.2.2 (2012-09-26)
    • Bugfix: small change to avoid using the “has_cap” function (deprecated). Thanks to @flynsarmy.
  • 0.2.1 (2012-01-02)
    • Bugfix when the og:image is not hosted on the same domain as the website/blog.
  • 0.2 (2012-01-02)
    • If the option is set to true, the same image obtained to the og:image will be added to the RSS feed on the “enclosure” and “media:content” tags so that apps like RSS Graffiti and twitterfeed post them correctly.
  • 0.1.9.5 (2012-01-02)
    • It’s now possible to choose how the post/page og:image tag is set. It means that if the user doesn’t want to use the featured/thumbnail image, or the first image in the post content, or the first image on the media gallery, or even the default image, he can choose not to.
  • 0.1.9 (2012-01-02)
    • Added the og:locale tag. This will be the WordPress locale by default, but can be chosen by the user also.
    • The og:type tag can now be set as ‘website’ or ‘blog’ for the homepage.
    • A final trailing slash can now be added to the homepage url, if the user wants to. Avoids ‘circular reference error’ on the Facebook debugger.
  • 0.1.8.1 (2011-12-12)
    • Fixed the namespace declarations
  • 0.1.8 (2011-12-12)
    • Type ‘website’ was being used as default for all the urls beside posts. This is wrong. According to Facebook Open Graph specification only the homepage should be ‘website’ and all the other contents must bu ‘article’. This was fixed.
    • On Category and Tags pages, their descriptions, if not blank, are used for the og:description tag.
    • If the description comes out empty, the title is used on this tag.
  • 0.1.7 (2011-12-12)
    • Changed the plugin priority, so that it shows up as late as possible on the <head> tag, and it won’t be override by another plugin’s Open Graph implementation, because other plugins usually don’t allow to disable the tags. If you want to keep a specific tag from another plugin, you can just disable that tag on this plugin options
  • 0.1.6 (2011-12-12)
    • Settings link now shows up on the plugins list
    • Small fix to ensure admin functions only are running when on the admin interface
    • Some admin options now only show up when the tag is set to be included
  • 0.1.5 (2011-12-09)
    • Fixed the way Categories and Tags pages links were being retrieved that would cause an error on WP 3.0
    • Added the option to use a Custom text as homepage og:description instead of the Website Tagline
    • Fixed a bug that wouldn’t allow to uncheck the og:image tag
  • 0.1.4 (2011-10-17)
    • Shortcodes are now stripped from og:description
    • Changed og:app_id and og:admins not to be included by default
  • 0.1.3 (2011-10-16)
    • Just fixing some typos
  • 0.1.2 (2011-10-16)
    • Fixing a bug for themes that do not support post thumbnail
  • 0.1.1 (2011-10-16)
    • Adding Open Graph Namespace to the HTML tag
  • 0.1 (2011-10-16)
    • First release

Please fell free to comment, ask any questions or make suggestions about the plugin using the comments bellow support forum on WordPress.org.

63 comentários a “WordPress Plugin: Simple Facebook Open Graph Tags”

  1. everything works great on this plugin except for the default fall back image… I can share a URL and choose from a number of thumbnails, but if I fb like it or fb comment on it, it chooses its own thumb

  2. Works fine on my home page and individual post, but when I go to an archive page I get:

    Fatal error: Call to undefined function get_queried_object() in /home/dave/public_html/wist/wp/wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/wonderm00n-open-graph.php on line 89

    I am running WP 3.0.4, which should be within the compatibility range or 3 or higher.

    Site is http://wist.info, but I’ll need to uninstall / deactivate this now in order to get my site back in operation. Unfortunate, because this plug-in gives some of the best control over Open Graph options.

    1. I’ve sent you a fix via email. Will you please try it and get back to me, so I can submit this bug fix as an update?

  3. Hi, thanks for making this plugin!

    I’ve installed it at ICanGiveYouHouse.com, but unfortunately it doesn’t seem to be publishing the titles or the description. Instead, all you see is the URL as the title and description. Also, the thumbnail is off and doesn’t show the default. Any idea what’s going on? Thanks for your help 🙂

    1. Hi there Andrew,

      The problem is not with my plugin. You have another plugin also inserting (wrong) tags

      Example: http://www.icangiveyouhouse.com/2011/11/06/monkey-monkey/

      My HTML:
      <!-- START - Wonderm00n's Simple Facebook Open Graph Tags -->
      <meta property="fb:app_id" content="171495592891053" />
      <meta property="fb:admins" content="10150378342877122" />
      <meta property="og:site_name" content="I Can Give You House" />
      <meta property="og:title" content="Monkey See Monkey Do" />
      <meta property="og:url" content="http://www.icangiveyouhouse.com/2011/11/06/monkey-monkey/" />
      <meta property="og:type" content="article" />
      <meta property="og:description" content="Tommy Trash is on a huge winning streak. Earlier this year, he released &quot;The End,&quot; immediately supported by Swedish House Mafia, as well as &quot;Future Folk,&quot; on Tiesto&#039;s buzzing record label Musical Freedom. His slew of remixes have also garnered massive play both on the in" />
      <meta property="og:image" content="http://www.icangiveyouhouse.com/audio/2011/11/Tommy-Trash-Monkey-See-Monkey-Do.jpg" />
      <!-- END - Wonderm00n's Simple Facebook Open Graph Tags -->

      A little bellow you’ll find also another plugin inserting the tags.
      Maybe Facebook is not liking this. Can you please de-activate the other plugin and get back to me?

  4. Hi – I have downloaded your plugin for Facebook Open Graph. However, when I ‘like’ some posts, the description does not display correctly on the facebook page. Rather than pulling content from the post itself, it says ‘You May Use These HTML tags & attributes…. (followed by some HTML code’. This does not happen for all posts. Are you able to help please? Thanks

  5. I just installed this and like it — it will use a page excerpt for the description whereas many OG plugins won’t. But I’d also like to be able to set the description for the homepage rather than just using the tagline. I can use All-In-One SEO to generate the necessary metadata, but that results in a duplicate “description” field, and the one from your plugin (with just the tagline) comes first and thus still shows. My tagline is used in my theme, so I can’t really change it . . . I just want a better and longer description when someone links to my site (and not a specific post) on FB.

    Any way to either add a field for a homepage description or simply not pull one from the plugin, so that it would use the metadata I can otherwise put in the homepage head?

    1. Well, it might not be an issue . . . disregard for now. The linter picks up the tagline, but for some reason when someone actually posts it (interesting that they did just after I wrote the earlier message), it’s picking up the “long” description.

      1. The linter is only getting the long description because the All in One SEO Pack og:description tag is appearing on the html source after my plugin og:description.

        Users not using the All in One SEO Pack might have this problem.

        You got a point. I’m going to update the plugin with this option.

  6. Seems a simple effective tool. Thanks. I am having an issued with the apid. I check the box and enter the ID, but when I go to debugger it shows it as an error that must be fixed…

    Object Invalid Value: Object at URL ‘http://epicbean.com/roaster-visit-dawson-taylor-coffee-boise/12/2011/’ of type ‘article’ is invalid because the given value ‘147598321984137’ for property ‘fb:app_id’ could not be parsed as type ‘fbid’.

    I’ve looked around but have found no solution. I guess I’ll just uncheck the apid option.

    G

  7. Thanks Marco. Might be cool to have that noted as lot of plugins ask for an APID so people just go find there page ID number and add that. Not sure why it’s so often requestsed in FB plugins if most people don’t have one.

    Anyways thanks for a great plugin. It seems to have fixed the issue and images are showing up when they like them just as they should.

  8. On a continued note. When I leave the ID unchecked it gives a “should be fixed line…

    fb:admins and fb:app_id missing. fb:admins or fb:app_id is necessary for Facebook to render a News Feed story that generates a high clickthrough rate.

    There’s also one that says… The og:locale property should be explicitly provided, even if a value can be inferred from other tags.

    Are these any real issue. And is it really of that much value to make your site an app as the article in the link talks about?

  9. Hi, and thanks for a great plugin!

    We are having a problem on our site in that the image tag is not being inserted.

    Here is an example url:

    http://facecrooks.com/Scam-Watch/get-christmas-theme-for-fb-on-cool-new-christmas-feature-or-theme.html

    When you view source, it shows the following tags:

    <meta property="og:description" content="Scam Signature Messages:

    Notice that the image tag is missing. We do have image selected in the settings and we have a default image url entered.

    Thanks for any help on getting this resolved!
    Tim

    1. Hi Tim,

      Thanks for your kind words on my plugin.

      This is indeed a weird issue and I’m not able to replicate it.

      What’s the WordPress version?

      Have you tried to activate other options to see if they show up?
      Right now you don’t have any open graph tags showing up…

      1. For some reason, all check boxes for the plugin were deselected. That would explain why no tags were showing up. I reconfigured the plugin and the image tag is showing up now. Hopefully it will stay that way.

        Thanks again!
        Tim

  10. We are having a problem is that when someone likes an article on Facebook the image being displayed is a random 125×125 ad from our site. We have the image tag configured and it is shown below:

    Do you know why facebook is selecting a random image instead of using the image assigned via open graph tags? We need to fix this because a lot of our fans are complaining about the ads showing up.

    Here is a link to how the ads are showing up:

    http://facecrooks.com/wp-content/uploads/2011/12/like_photo_issue.jpg

    Thanks!

  11. hi, you resolve almost my problem with the facebook like button, but I got this problem now:

    Unknown Object Type: Object at URL ‘http://metalveg.org/’ is invalid because the configured ‘og:type’ of ‘metalveg’ is invalid.

    How can i resolve?

    Thank you

    1. You have AT LEAST 3 different plugins creating Open Graph Tags. Mine is showing “website” as og:type correctly. You have another one as “blog” and another as “metalvag” which is incorrect.

      My code is only this:
      <!-- START - Wonderm00n's Simple Facebook Open Graph Tags -->
      <meta property="fb:app_id" content="286831618034137" />
      <meta property="og:site_name" content="MetalVelg" />
      <meta property="og:title" content="MetalVelg" />
      <meta property="og:url" content="http://metalveg.org" />
      <meta property="og:type" content="website" />
      <meta property="og:description" content="Il Blog dell&#039;Heavy Vegan style" />
      <meta property="og:image" content="http://metalveg.org/wp-content/themes/atahualpa/images/Metalico.png" />
      <!-- END - Wonderm00n's Simple Facebook Open Graph Tags -->

      Please try to de-activate the plugins creating this:
      <!-- Begin Fix Facebook Like WordPress Plugin -->
      <meta property="og:title" content="MetalVelg"/>
      <meta property="og:type" content="metalveg"/>
      <meta property="og:url" content="http://metalveg.org"/>
      <meta property="og:image" content="http://metalveg.org/wp-content/themes/atahualpa/images/Metalico.png"/>
      <meta property="og:site_name" content="MetalVelg"/>
      <meta property="fb:admins" content=""/>
      <!-- End Fix Facebook Like WordPress Plugin -->

      And this:
      <meta property="og:site_name" content="MetalVelg" />
      <meta property="og:title" content="MetalVelg - Il Blog dell&#039;Heavy Vegan style" />
      <meta property="og:type" content="blog" />
      <meta property="og:url" content="http://metalveg.org/gnocchi-ignoranti/" />

      And this:
      <meta property="fb:admins" content="http://www.facebook.com/VeganRover" />
      <meta property="fb:app_id" content="286831618034137"/>
      <meta property="og:image" content="http://metalveg.org/wp-content/themes/atahualpa/images/Metalico.png"/>
      <meta property="og:site_name" content="MetalVelg"/>

        1. I don’t have a clue which plugins you have installed. You’ll have to de-activate/activate one by one until you get the desired tags on the html code just once!

          Because other plugins do insert Open Graph tags on the html code, my plugin has the ability to chose which tags you do or don’t want to inlude.

  12. Hi,

    Nice plugin.
    I only have one small issue and one request please:

    The Issue:
    On the home page of our blog, the og:url metatag is missing a trailing slash on the URL.

    Needs to be:

    See the difference? /blog has to be /blog/
    The facebook linter debug tool gives circular reference error. http://developers.facebook.com/tools/debug/og

    Two Requested Improvements:
    1. Please make the og:type for the blog home page a configurable setting (blog or website)
    2. Please add the og:locale as an optional configurable additional tag that can be added

    If the issue could be addressed and these small improvements, we could use your plugin for several of our client blogs and I would definately make a donation through PayPal.

    Cheers,
    Bob

    1. Hi there.

      Can you give the the URL?

      Regarding the trailing slash at the end, this is something your server should redirect and Facebook should not have a problem with that. Anyway, I’ll take a look at this and also at your suggestions and get back to you.

      1. Hi Marco,

        Sorry for the huge delay in getting back to you on this!!
        We’ve been extremely busy here in Jan on some other projects. Anyway just swinging back to this now.
        Thanks for all your recent updates. That’s wonderful.

        Regarding this issue with the trailing slash. Yes its still an issue.
        Our wordpress installations are both on windows servers.
        I have listed two URLs below of the two blogs where we have installed your plugin and both are giving an error in the Facebook open graph debugger tool : http://developers.facebook.com/tools/debug

        Here are the URLs that have the trailing slash issue:
        http://www.brantflorist.com/blog/
        http://www.burlington-homes.com/blog/

        Here is the WordPress Address URL/Site URL in the Blog’s general settings tab: http://www.brantflorist.com/blog
        I’ve tried to add the training slash in the WP General Settings tab for the blog, but when I click save, it just removes the trailing slash.

        Thanks,
        Bob

        1. Hi Marco,

          My Mistake! I am not paying attention… obviously!
          I just now see that you added the checkbox to add trailing slash to the URL of the home page!

          YES… this works perfectly!!!
          No more errors from the linter debugger.
          All looks good

          So at this point, I have no issues, the plugin appears to be working perfectly under WordPress 3.2.1 and 3.3.1 under Windows (wordpress, php, mysql)

          Thanks!
          P.S. I sent you a donation today!

    2. Bob,

      A new version wan released (0.1.9). Please check it out and if everything’s is according to requested please give a high rating to the plugin on the WordPress website and fell free to make that donation you mentioned 😉

      1. Hi Marco,

        Sorry for the delayed reply to your changes.
        We’ve been busy and I forgot to check the check box to get notified when you replied to my first post. Sorry about that!

        Yes the changes for the HomePage type and Locale are perfect!
        I have just installed version 0.2.1 today.

        Thanks for these changes.
        I have just sent you a donation via PayPal.
        Also please me reply to your reply about the missing trailing slash on the image URL.

        I will now go to the Facebook plugins page and give you a high rating!

        Regards,
        Bob

        1. Sorry… I mis-spoke in the above reply.
          It’s the missing trailing slash in the og:url tag.

          We need a slash on the end for some reason.
          Perhaps this is a quirk when running wordpress on a windows server.

          1. Hi Marco,

            My Mistake! I am not paying attention… obviously!
            I just now see that you added the checkbox to add trailing slash to the URL of the home page!

            YES… this works perfectly!!!

            Thank You!

  13. Hi!

    I’m having a couple of problems that others are talking about. Big problem is that the featured image, which shows in the og;image tag on the page isn’t being picked up by FB. Look at this page as an example:

    http://theboatgalley.com/food-storage-bins/

    When I used the linter or actually post it as a link on my wall (or using PostCron), it’s picking up the wrong image . . . and often doesn’t pick the same image twice in a row. There are no other plugins putting in og tags, so I’m lost as to the problem. I notice this happening a couple times a week, then for some reason FB will pick things up correctly again. Any ideas??

    I’ve also had the problem that Tim talked about — suddenly all the check boxes being de-selected. It’s happened three different times, without me doing anything.

    NOTE: I don’t use a Like button or Like box plugin — both are hardcoded.

    Thanks for any help you can give me — and Happy New Year!

    1. Hi there Carolyn,

      First of all on the URL you provided me, no tags are visible. Maybe the “all checkboxes deselected” problem again?
      Can you please re-enable at least the image option so that I can try to debug your problem?

      Be aware that PostCron, RSS Graffiti and other auto-posters to Facebook sometimes use their own method of getting the image they then post to Facebook, ignoring the og:image tag. There’s absolutely nothing we can do about that.

      Regarding the problem of the check boxes being magically deselected I can’t seem to find the problem… Can anyone give me an hint? In what situation did this happen?

      1. Currently, all the check boxes are selected and the linter is picking up everything correctly on an article I just edited. So I checked the article I’d given you the URL for . . . it was still wrong. I re-saved (hit Update) and now it’s showing correctly in the linter, too.

        I guess it’s something on my end . . . so I guess I have to go back through all my posts and “Update” (most of my posts are evergreen type, so people do post links and shares to old ones).

        No clue why it’s happening . . .

        1. Carolyn,

          Facebook DOES caches the images associated with each url.

          This means that if you share a url of your website PRIOR of having the correct og:image tag, Facebook will choose an image and stick with that image for some time, even if you now have the correct og:image tag.

          Cheers,
          Marco

    1. I just can’t understand… Nowhere in the plugin code there’s a routine to reset all checkmarks to “unchecked”. There are defaults that are imposed when the pluginis first activated but it’s not “all unchecked”.
      Can’t help you for now. I must understand why this is happening…

  14. Hi man,

    I’m using your plugin from some time now and it’s perfect (almost perfect to be honest:)

    I have one small problem on my website: http://www.tarzanija.com

    I’m planing to split my posts on two pages (if they are too big) by using WP inbuild tag. Now, everything is working great, but when I go to my second page of the article: http://www.tarzanija.com/article-name/2/ Open Graph plugin use that URL (naturally) and when someone like my second page of the article on their wall is the link to just that page (my likes are divided).

    Is it possible to somehow edit you code to set the plugin to use page one URL [www.tarzanija.com/article-name] instad of [www.tarzanija.com/article-name/2/] even if you are at the second page of the artice?

    Guys from Cracked.com solved that problem but I doubt they will tell me 🙂

    Sorry for a long question.

    Thx again for the great plugin!

    Cheers,
    Radomir Basta

  15. Hi Marco!

    I just upgraded to WP 3.3.1 to fix some other problems, but now this plugin does nothing (I know, you say it’s only compatible up to 3.2). Any chance you’ll be doing an upgrade that IS compatible? I love the way it works!

    1. Hi Carolyn,

      I’m also using 3.3.1 on ALL my WordPress blogs and the plugin is working great.

      Are you sure you have the plugin active? Also all the options on the plugin configuration?

      Cheers,
      Marco

    1. Hi there,

      Right now I don’t have any plans to add 3rd party plugins integration.

      What I could do is to give the user the ability to use posts custom fields as titles, descriptions, etc..

      Would this work for you?

  16. Hi Marco, I really like your plugin. Can you help me with something?
    I installed the plugin and it’s working fine but I can’t change its settings: I don’t see the “save changes” button and I only see 3 groups of settings. Here’s an image: http://i.imgur.com/Ekphd.png

    What could be the problem?

    1. Now that’s weird!! Look -> http://imgur.com/MirM1

      You’re not even seeing the rest of the options.

      Do you have the latest version installed?
      Try to disable other plugins, one by one, just for testing propouses so we can figure out if it’s any compatibility issue with another plugin.

      Get back to me if you get any conclusion.

Os comentários estão fechados.