Title: Adding code to an Archive page
Last modified: August 20, 2016

---

# Adding code to an Archive page

 *  Resolved [elhashbrown](https://wordpress.org/support/users/elhashbrown/)
 * (@elhashbrown)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/adding-code-to-an-archive-page/)
 * 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');`
 * 
 * Anyone got any ideas?
 * [http://wordpress.org/extend/plugins/addthis/](http://wordpress.org/extend/plugins/addthis/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Kiran](https://wordpress.org/support/users/kirankr/)
 * (@kirankr)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/adding-code-to-an-archive-page/#post-3151374)
 * 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');`
 *  Thread Starter [elhashbrown](https://wordpress.org/support/users/elhashbrown/)
 * (@elhashbrown)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/adding-code-to-an-archive-page/#post-3151395)
 * 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>
       </div>
       ```
   
 * 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.
 *  Thread Starter [elhashbrown](https://wordpress.org/support/users/elhashbrown/)
 * (@elhashbrown)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/adding-code-to-an-archive-page/#post-3151398)
 * `wp_title('','0')`
 * corrected the title. A tags still empty.
 *  Thread Starter [elhashbrown](https://wordpress.org/support/users/elhashbrown/)
 * (@elhashbrown)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/adding-code-to-an-archive-page/#post-3151405)
 * 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>`
 *  [Kiran](https://wordpress.org/support/users/kirankr/)
 * (@kirankr)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/adding-code-to-an-archive-page/#post-3151442)
 * Hi,
 * 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>`

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Adding code to an Archive page’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/addthis_70cced.svg)
 * [WordPress Share Buttons Plugin – AddThis](https://wordpress.org/plugins/addthis/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/addthis/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/addthis/)
 * [Active Topics](https://wordpress.org/support/plugin/addthis/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/addthis/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/addthis/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Kiran](https://wordpress.org/support/users/kirankr/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/adding-code-to-an-archive-page/#post-3151442)
 * Status: resolved