Support » Plugins » Hack AddThis plugin to place button outside the_content

  • Is it possible to edit the plugin code so the button the AddThis plugin places on the page is not inside the “storycontent” div, but outside it?

    They are using this line, I believe to place the plugin output:

    add_filter(‘the_content’, array(&$this, ‘social_widget’));

    Is there a way to edit this line, so it drops its div elsewhere? perhaps into a custom field?


Viewing 6 replies - 1 through 6 (of 6 total)
  • You’ll have to hack the plugin file. Comment out the line that has:

    add_filter('the_content', array(&$this, 'social_widget'));

    Then create a wrapper function for social_widget()

    public function print_social_widget( ){
        print $this->social_widget( '' );

    Add a new custom action which will call our wrapper function, this can be placed below the line that we commented out before.

    add_action( 'custom_social_widget', array(&$this, 'print_social_widget'));

    Now go to your template and add the following code to your template files where you would like the button displayed:

    <?php do_action( 'custom_social_widget' ); ?>

    Let me know how this works for you.

    Thanks! That worked perfectly.

    No problem!

    Thanks again, but I’ve run into an odd wrinkle, which is that, though the AddThis button shows up fine for the entries on the main, unfiltered Blog page and on individual blog entries, it disappears when you click on a category link to filter the blog page down to a single category. Any idea why that might be happening?


    your theme most likely has a category.php or archives.php file in it. you will want to add the same code <?php do_action( 'custom_social_widget' ); ?> to the loop in these files too.

    Hmm… this hack no longer works in the new addthis plugin, as they seem to have restructured it a bit when adding a sidebar option.

    The string in question has been changed to:

    add_filter('the_content', 'addthis_social_widget');

    Any suggestions on how to adapt?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Hack AddThis plugin to place button outside the_content’ is closed to new replies.