Ready to get started?Download WordPress


Smart Website Tools by AddThis
Not showing on Blog Page, only on Single posts (3 posts)

  1. Collin Donahue-Oponski
    Posted 1 year ago #


    I believe I've found a bug around line 1335 of addthis_social_widget.php:

    // Pages
        elseif ( is_page() )
            $display = (isset($options['addthis_showonpages']) && $options['addthis_showonpages'] == true) ? true: false;

    Here is what I think is happening. You are hooked onto the_content filter, which usually gets called from within The Loop. However, you are using is_page(), which explicitly in the docs does not work from within The Loop. What is more appropriate, is to make use of the 2nd paramater for filters on the_content, and then call is_page() and pass the ID of the current post in case you're within the loop.

    Here is a code sample from the plugin I maintain, in case it is useful:

    add_filter('the_content', 'myplugin_add_to_post', 999, 2);
    function myplugin_add_to_post($content, $id = NULL) {
        if (empty($id)) $id = get_the_ID();
        // Workaround for bug in WP < 3.3 where title filters are passed the entire post object instead of just the id
        if (isset($id, $id->ID)) {
            $id = $id->ID;
        // Now it is safe to assume the $id is correct
        if (is_page($id)) {
            // Do something (or not)

    I apologize in advance if the formatting is terrible. There is no preview functionality.


  2. Collin Donahue-Oponski
    Posted 1 year ago #



    $accepted_args parameter of add_filter

  3. Srijith V
    AddThis Samurai
    Plugin Author

    Posted 1 year ago #

    Thanks for the tip! Yea, it seems to be a wrong implementation. We will try to add this fix to the upcoming release. Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic