Getting the Digg button in WordPress to work

July 4, 2008 · Posted in Technical · 5 Comments 

There are a number of posts out there on getting the Digg button into WordPress – I ended up using snippets from a couple of them, and thought that it might be helpful for someone else.

I added the following code to my archives, index, and single post files:

<div style=”float:left; margin-right:10px;”>
<script type=”text/javascript”>digg_url = “<?php the_permalink(); ?>”</script>
<script src=”http://digg.com/tools/diggthis.js” type=”text/javascript”></script>
</div>

I inserted the code immediately above the <?php the_content (‘<p>Read the rest of this entry &raquo;</p>’); ?> line in each of the files.

The div style lines puts the button floating (instead of above the post) and to the left with a 10 pixel margin.

The permalink line makes sure that the correct link is used for Digg submission – before I put in this snippet of code, the Digg button on my main page referenced the home page instead of the post. This meant that that Diggs could possibly be split across multiple submissions for the same content. For example, prior to inserting the permalink snippet, the Digg button on my main page for a prior post showed a “Submit” option instead of the Digg count.

Hope this helps someone out!

Add to Del.cio.us RSS Feed Add to Technorati Favorites Stumble It!