Getting the Digg button in WordPress to work

July 4, 2008 · Posted in Technical 

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

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!

Related Posts:

Comments

5 Responses to “Getting the Digg button in WordPress to work”

  1. Suburban Survivalist Blogger on July 6th, 2008 11:24 pm

    I used your code on my site, and it work great! Thank you for putting that together. I’ve been fiddling with it for a few days now and never could get it ‘just right’.

    Good job!

  2. moneyloveandchange on July 7th, 2008 9:14 pm

    I am glad that it helped someone! I know that a lot of EC people just started with Digg (myself included), so I thought it would be useful to post.

    Thanks for letting me know it worked for you :)

  3. Atniz on July 9th, 2008 9:35 am

    I haven’t start using digg yet. Entrecard family now encourage us to use digg. Thanks for making my work easier.

  4. gsmith on July 23rd, 2008 10:34 am

    I just added to my single page posts, as it seemed to slow down overall page load times when loading on the main index page. But, it works perfectly!

    Thanks for the code, I had been looking for something similar.

    gsmiths last blog post..Terrorist Screening Database - The Terrorist Watch List

  5. moneyloveandchange on July 24th, 2008 11:13 am

    gsmith, I can see that you took it off your index page to save time - great idea! Thanks for posting :)

Leave a Reply