How to Insert the AddThis Button after Each WordPress Blog Post


Would you your WordPress blog visitors to be able to Like, Bookmark, Tweet, Digg, Email, and share in many other ways your blog posts? Then use the AddThis button or widget found at www.addthis.com. You probably already have acquired the code one or you wouldn't be here, but check their site often as they do come up with new designs.

Before providing the instructions, we assume that you are experienced in manually editing your WordPress php files, understand the importance of keeping track of all changes should you need to restore your blog or update your blog theme, OR - better yet - that you are using the Child Theme method for manually customizing your WordPress Blog. (WordPress has several great tutorials on using Child Themes).

Also, this method works on the themes we work with, but with so many themes out there, yours may be completely different..

So ... to add the code for your AddThis Share button to appear after each WordPress blog post, follow these steps.

After logging in to WordPress admininstration, click "Editor" under "Appearance." Find the section that begins with <div class="postentry"> and find the ending </div>. (The div after the insertion area is <div class="postmetadata"> for most WordPress themes.)

Insert the AddThis code as shown below in red. Naturally, the commends are not part of the actual code, but AddThis usually adds them for you automatically, so we recommend you keep them.

Also, make sure you substitute your AddThis pubid name or number where, in the code, it reads: YOUR-ID-GOES-HERE. You will see this twice as the code below includes the clickback option.

Also, we added the break <br /> at the very end because it looked nicer, but it is not required, of course.

<div class="addthis_toolbox addthis_default_style""><!-- AddThis Button BEGIN -->
<a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;pubid=YOUR-ID-GOES-HERE"
addthis:url="<?php the_permalink(); ?>"
addthis:title="<?php the_title(); ?>">
<img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a></div>
<script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4d9a0d1d5db3b34f"></script><!-- AddThis Button END -->
<br />

If you would like to have the AddThis Share (or Bookmark) Button display on the WordPress blog post when someone clicks on the post title (permalink), follow the same steps above regarding adding the code but edit the file single.php instead.

If you would like to have the AddThis Share (or Bookmark) Button display on the WordPress blog post when someone is viewing the post from the archive as well, follow the same steps above regarding adding the code but edit the file archive.php instead.

Hope this works for you as it does for us. Cheers!

If this post has been helpful, please consider linking to our blog or sharing!
Bookmark and Share

2 comments: