You’ve seen those Digg This buttons on many sites and blogs, but did you know how to add them?

Here’s an example (it’s an image, so you can’t click on it):

Digg This button

Well, as usual, it’s a plugin: Digg This from Aviran’s Place. The plugin is pretty easy to use once you figure it out, and here is how it works:

  • The button is invisible until someone diggs your post at least once. It took me a while to figure this out, since I added the php tag and nothing was happening.
  • When someone diggs the post, the button appears and you get an email notification telling you someone dugg your article, what category it was dugg in, and the link to the post. Very useful!
  • The text under the number of diggs says “digg this” until you’ve dugg it, and then it says “dugg!” (like in the image above). This is to prevent double digging.

The directions on the plugin page are pretty confusing, so here are easy directions for implementing the Digg This plugin:

  1. Upload the plugin and activate it.
  2. Add the php code below to the relevant template files where you want the button to appear. These files generally include home.php, index.php, archive.php, category.php and search.php. You may not have all of these files in your theme, but don’t worry – not every theme needs them. The code to add is as follows:
    <div id="digg"><?php digg_this_button(); ?></div>
    Add it right above the code that looks something like this:
    <?php the_content('Read more»'); ?>
  3. Now you need to style the button, or else it will just appear floating randomly above your text. So open style.css and add the following style:
    #digg {
    float: right;
    }

    This causes the button to float to the right of the content at the top. You can use float: left; if you prefer it to be on the left-hand side.

That’s it! Now write that killer post and wait for the world to digg it and bring your site down – blogging success!

I implemented this over here on a post that’s been dugg, so you can take a look at an example if you want: New time travel theory – pretty freaky.

(No, this hasn’t been implemented here at WordPressGarage.com. It’s the classic example of the shoemaker going barefoot. This whole blog needs a rehaul, but that will only happen when I have some more of that precious commodity known as time. If only they sold time on ebay…)