Home > Misc > AddThis WordPress Plugin Facebook Sharing Patch

AddThis WordPress Plugin Facebook Sharing Patch

February 18th, 2010 Leave a comment Go to comments

A few days ago, we’re not sure the exact time, something changed which caused problems when sharing an AddThis WordPress plugin enabled blog page to Facebook. The FB shares do not have the correct page title, description or images. This problem actually affects any page that uses the AddThis code specified in the technical section later in the post. However, we are only going to address the plugin related problems at this time and provide you with a simple patch.

Here’s a quick little patch for the WordPress AddThis plugin. Follow these instructions at your own risk. This patch has only been tested on WP 2.9.2 and AddThis Social Bookmarking Widget 1.6.1. We do not guarantee the patch nor do we take any responsibility if something breaks.

This patch will only fix pages that are considered by WordPress to be A Single Page, Single Post or Attachment (WP Codex: is_singular). These pages are probably the majority of your important shares.

  1. Right click and “save as” or “save linked file as” to get the file:
  2. Make a backup of the existing file on your server:
    • /wp-content/plugins/addthis/addthis_social_widget.php
  3. Change the file extension of the file you just downloaded from .txt to .php and then upload to your server and overwrite the old file:
    • /wp-content/plugins/addthis/

For the people who want to know. Here’s the technical bits.

For some reason (we don’t know why) Facebook fails to parse the pages correctly due to the AddThis Attribute-based Configuration code.

Specifically: addthis:url=”http://example.com” addthis:title=”An excellent website”

The patch we provided replaces those attributes on WP is_singular pages with JavaScript Configuration code.

var addthis_share =
url: "http://www.example.com/",
title: "Example Title"

Actual code edits in the patched file around line #317:

// begin facebook hack
if ( is_singular() ) {
$content .= 'var addthis_share = { url: "' . $link . '", title: "' . $title . '" }' . "\n";
$share_options = '';
else {
$share_options = 'addthis:url="' . $link . '" addthis:title="' . $title . '"';
// end facebook hack -- replace addthis:url and addthis:title with $share_options in 2 locations below

This fix is only meant as a quick patch until the AddThis team releases an official update to their plugin.

  1. March 8th, 2010 at 00:48 | #1

    I successfully downloaded and installed the patch. It worked for a few days, but on March 8, 2010, AddThis sharing failed again.

  2. March 8th, 2010 at 23:12 | #2

    Hi RK,

    I just tested your blog and everything looks fine in regards to AddThis and Facebook. I get the right title and image. However, the description looks wrong. I viewed the source of the page and the meta description (meta name=”description” contents=”description of page”) does not appear to be what you intended. The source suggests that the description is being generated by another plugin; META Tags added by Add-Meta-Tags WordPress plugin.

  1. No trackbacks yet.