Support » Plugin: Share Buttons by AddThis » Adding code to an Archive page

  • Resolved elhashbrown


    I would like to add the AddThis Widget to the Archive pages for a particular taxonomy. However I require the AddThis links to be to the Archive and not to the individual posts. I have a template for this taxonomy set up and have tried to add the following code.

    do_action('addthis_widget',get_permalink($post->ID), get_the_title($post->ID), 'fb_tw_p1_sc');

    Nothing shows up in the page and in the code only part of the AddThis code is generated which shows that it is trying to produce links for the last post in the list (not the Archive itself). The tags are also empty.

    Anyone got any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The code you specified generates the AddThis button linked to the current post id.

    You might need to use a variation of the above code in your template to show the AddThis buttons linked to the URL (of the archive) of your choice.

    do_action('addthis_widget', [permalink to the archive page], [title of the archive page], 'fb_tw_p1_sc');

    Thanks Kiran, I’ve got a little closer. using the following:

    $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    		do_action('addthis_widget',$current_url, the_title_attribute('echo=0'), 'fb_tw_p1_sc');

    Produces this in the page:

    <div class="addthis_toolbox addthis_default_style " addthis:url="The Taxonomy Archive URL" add this:title="The title of the last post"  >
    <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
    <a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
    <a class="addthis_counter addthis_pill_style"></a>

    The Title is wrong but I expect I can get this filtering wp_title. There is nothing in the A tags however so it doesn’t look like this is going to work whether the title is correct or not.


    corrected the title. A tags still empty.

    The answer turned out to be simple – the Addthis javascript needed to be added:

    <script type="text/javascript" src=""></script>


    Nice to hear that the issue is resolved for you.

    By the way, to get the latest version of AddThis UI, you can use 300 instead of 250, in case you are not aware of this.

    <script type="text/javascript" src=""></script>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding code to an Archive page’ is closed to new replies.