Support » Plugin: Share Buttons by AddThis » Not showing on Blog Page, only on Single posts

  • Hi,

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Not showing on Blog Page, only on Single posts’ is closed to new replies.