Share Buttons by AddThis
[resolved] Adding code to an Archive page (6 posts)

  1. elhashbrown
    Posted 3 years ago #

    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?


  2. Kiran
    Posted 3 years ago #

    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');

  3. elhashbrown
    Posted 3 years ago #

    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.

  4. elhashbrown
    Posted 3 years ago #


    corrected the title. A tags still empty.

  5. elhashbrown
    Posted 3 years ago #

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

    <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>

  6. Kiran
    Posted 3 years ago #


    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="http://s7.addthis.com/js/300/addthis_widget.js"></script>

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Share Buttons by AddThis
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic