How to show digg score in WordPress.

July 24th, 2008 | Yaz

If you can edit theme files, you can easily automate adding digg score to the posts. Edit index.php and single.php and add the following code to the Loop:

<?php if ( get_post_custom_values(“digg”) != 0) {
$metadigg = get_post_custom_values(“digg”);
echo “<script type=\”text/javascript\”>
digg_url = ‘”.$metadigg[0].”‘;
digg_bgcolor = ‘#999900’;
digg_window = ‘new’;
</script>
<script src=\”http://digg.com/tools/diggthis.js\” type=\”text/javascript\”></script>”;
} ?>

Next, after submitting a post to digg.com, copy the url of the post on digg.com. Edit the post. Scroll down to “Costum Fileds” and add key “digg” with value equal to the url on digg. For example, url of this page on digg.com is: http://digg.com/software/How_to_show_posts_digg_score_in_Wordpress

so I should add key “digg” with value “http://digg.com/software/How_to_show_posts_digg_score_in_Wordpress”. Save and publish the post. Now, you should be able to see digg score of your post.

To show a compact version of the digg score icon, use the following code instead:

<?php if ( get_post_custom_values(“digg”) != 0) {
$metadigg = get_post_custom_values(“digg”);
echo “<script type=\”text/javascript\”>
digg_url = ‘”.$metadigg[0].”‘;
digg_bgcolor = ‘#999900’;
digg_skin = ‘compact’;
digg_window = ‘new’;
</script>
<script src=\”http://digg.com/tools/diggthis.js\” type=\”text/javascript\”></script>”;
} ?>

Leave a Reply

Your email address will not be published. Required fields are marked *