
photo credit: John Pastor
Believe it or not there is a right way and a wrong way to do this. Most wordpress blog templates use the content tag on the main index page, meaning it shows full posts unless you use a more tag. If you use a more tag it will truncate the post at that tag and give you a link to read the full article.
There are many plugins that will insert digg badges into your posts and pages, but I’ve found many of them either slow down your site or are more trouble then they’re worth and limiting in styling options (I like to be able to insert it EXACTLY where I want and not have to use proprietary plugin tags that could break my theme when I upgrade wordpress. If you’re interested in using a plugin here are a few I’ve looked at before( diggZ-Et , digg widget , WP-EasyDigg ). I personally prefer to have a compact digg button placed nicely in a float box with the author image and link on my blog posts. Now the main reason I wrote this, wasn’t to discuss matters of taste, but it’s because if you add the digg button javascript directly to your template off the digg tools site you’ll run into a VERY annoying problem that will GREATLY decrease the traffic to your site from digg.
Like I mentioned above, that most wordpress templates use the content tag to display full posts and most bloggers make use of the more tag at least occationally you’ll notice that wordpress automatically appends #more-### to the end of the url when you click the link to continue reading the full post (where ### is the specific numbered id of the post). The problem is this URL is recognized as a separate and different url from the permalink without the #more-### appened to this. This means that if some digs the #more version by clicking on the digg button when viewing your site, it will not show up when the post is viewed directly or using any other link.
This means that many visitors may try to resubmit your blog post to digg and won’t have an accurate number of how many digs it’s received. This can cause frustration and less votes, resulting in less traffic. The fix is VERY simple. Digg allows you to specific which url to use directly in it’s javascript. By default it will use whatever URL the user clicked or whatever is showing at that time in the address bar (which will include appeneded commands and extra info like the #more example above. To make sure that all the visitors to the page are digging the same URL you can use the wordpress permalink template tag to tell digg to ALAWAYS use the simplest direct url to that post.
In the simplest form the digg button with javascript has no paramenters. It looks lik:
<script type=”text/javascript”></script>
<script src=”http://digg.com/tools/diggthis.js” type=”text/javascript”></script>
That will display a large digg button with no other options and use whatever URL is in the visitors address bar resulting in the problems listed above. To fix the URL issue add this parameter to the javascript digg button
digg_url = ‘<?php the_permalink(); ?>’;
So our button now looks like this:
<script type=”text/javascript”>
digg_url = ‘<?php the_permalink(); ?>’;
</script>
<script src=”http://digg.com/tools/diggthis.js” type=”text/javascript”></script>
I personally prefer to make the button compact and the link to open in a new window so I adjust my digg button to look like the following:
<script type=”text/javascript”>
digg_skin = ‘compact’;
digg_window = ‘new’;
digg_url = ‘<?php the_permalink(); ?>’;
</script>
<script src=”http://digg.com/tools/diggthis.js” type=”text/javascript”></script>
Now you can put this code directly into any template where you want the digg button to show up in. I personally use it only in the posts template, but you can play around with what you like and where you want it in the theme editor.
3 Responses
Leave a Reply
Hi, I simply stopped by this site to state that these templates are fantastic. Carry on the truly amazing work, I’m going to look a bit more. Thank you!
What an excellent tutorial! clear, concise, and informative. Thanks for the helpful sharing! Keep it up, as it were.
Cheers
Jaiden
hi i did it.you made it really simple.Thanx for sharing.