Do you want to add a digg this button to your site that will automatically submit your post to digg?
I have tried a lot of different plugins and all are either missing customizations that I wanted or had some weird color scheming or used IFRAMES…haha.
Well I went to the digg site and they had a section on integration: FANTASTIC.
I saw the variables that needed to be filled out and I saw how we could do that automatically with wordpress.
The code boiled down to the following:
<div style=”float: right; width: 75px; padding-top: 10px; margin-left: 5px;”><script type=”text/javascript”>
digg_url = ‘<?php the_permalink() ?>’;
digg_bgcolor = ‘#000000′;
digg_window = ‘new’;
digg_title = ‘<?php the_title(); ?>’;
digg_bodytext = ‘<?php the_excerpt_rss(); ?>’;
</script>
<script src=”http://digg.com/tools/diggthis.js” type=”text/javascript”></script></div>
So whats this all mean? Where does it go? I am here to explain all. First off, it goes in your single.php. If this doesn’t exist, its because your theme named it something else. This section can be found by clicking “editor” in your appearance menu. It will then open a theme menu and on the right you will want to chose single, or single post, or something that looks similar to that. If your not sure, do something simple like add the word “test” at the very top of the code, save it and look at your main page. It shouldn’t show up, but if you click on a single story, the word test will be at the very top left of the page. Good you found it.
Now we will need to paste the special code into the rest of the single.php code.

Like I shown here, it will need to go right above “php the content.” php the content is a way for the server to say, “hey that stuff he typed goes here.” As you can see, we used a lot of php calls in order for our digg script to automatically submit information that we already filled out.
Now heres where I explain everything bit by bit for you curious minds.
<div style=”float: right; width: 75px; padding-top: 10px; margin-left: 5px;”> This part is saying, hey, put a transparent sheet on the website, make it float to the right, make it 75 pixels wide and put some space around it on the top and left. Feel free to change these to your sites likings. You can have it float to the left, make it have very little space from the text, whatever you want.
<script type=”text/javascript”> This is saying to the server, “hey, this next bit of code isnt text, they are instructions, to pay attention!”
digg_url = ‘<?php the_permalink() ?>’; When you submit to digg, you usually have to fill out the URL of the digg submit. We are using a php variable built into wordpress that is the link that never changes. You can see the permalink at the top of your page when you are writing.

See? Cool right.
digg_bgcolor = ‘#000000′; Simple enough, whats the background color? This is done in hex. If you dont know these there are plenty of sites with free color generators.
digg_window = ‘new’; How should I treat this link? Well I want you to stay at my site, so the link will open in a new window.
digg_title = ‘<?php the_title(); ?>’; Whats the title? Well once again we are going to be using the wordpress php integration to fill this out. This is actually the title that you made your post.
digg_bodytext = ‘<?php the_excerpt_rss(); ?>’; This one was a bit more tricky. What do you want it to say in the body below the digg link. Well we dont want the entire post in there, but we do have this neat little feature when writing a post called the exerpt. Its mainly only used for the RSS feeds, but it will work wonderfully for this. The exerpt field is right below where you post your actual body of information. I suggest you make your exerpts very well, including most of the details of your post.
</script> This basically tells the server, hey im done sending you instructions, the rest is text. Notice how commands are sent with brackets <> and ending commands are </> finished brackets. Also multiple commands are seperated with ; semicolons.
<script src=”http://digg.com/tools/diggthis.js” type=”text/javascript”></script></div> This last part is the server actually getting the script that does all the work for us from the digg site and then ending the transparent window and its own script.
I hope this gave you a bit of insight on how php and wordpress works as well as give you a nice little digg button on your site! explination
Add Digg to your wordpress. | I am KrAzE – How to,……
Bookmarked your post over at Blog Bookmarker.com!…
@diy: Awesome, thanks!
I believe you can move diggthis.js to your own server so that people with noscript can see it (assuming they allow base domains by default).
Good tutorial.
@fuzion: Good point~