Multiple AddThis in WordPress Loop

Continuing on with my previous post, this post shows how to have multiple AddThis instances on the same page. This is especially useful if you have a WordPress loop (such as an article index, or just your normal blog loop on your main page).

First of all, start your loop:


Then where you want to list the preview of the blog post, or the blog post content entirely, just slip in the addthis bit where you want it to display:

<div id="home-news-post">
<div class="storytitle">
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
<div class="time" style="float:left; margin-top:5px; margin-left:10px;">
<?php the_time('d.m.Y') ?>
</div>
<div class="addthis_toolbox addthis_default_style" style="margin-left:15px;">
<a class="addthis_button_facebook" addthis:url="<?php the_permalink(); ?>" addthis:title="<?php the_title(); ?>" ></a>
<a class="addthis_button_twitter" addthis:url="<?php the_permalink(); ?>" addthis:title="<?php the_title(); ?>" ></a>
<a class="addthis_button_email" addthis:url="<?php the_permalink(); ?>" addthis:title="<?php the_title(); ?>" ></a>
<div class="hide_fb_like"><a class="addthis_button_facebook_like" addthis:url="<?php the_permalink(); ?>" ></a></div></div>

<script src="http://s7.addthis.com/js/250/addthis_widget.js#username=your_user_name" type="text/javascript" charset="utf-8"></script>
</div>
<div class="storycontent">
<?php the_content(); ?>
</div>
</div>

The bits required to make it work with multiple instances are highlighted in bold

One thought on “Multiple AddThis in WordPress Loop

Leave a comment