How to add a dynamic digg vote this button, show related posts and more using Wordpress |
Regular readers through the website might have noticed a few changes recently at the site. Recently, I added a couple additional Wordpress plugins to the site with some minor custom configuration and also integrated an AJAX-style Google search option on the search results page. None of these changes took much time, but they added some nice functionality to the site which I’ll share in detail below.

Dynamic digg plugin
The first was the Digg vote button which will dynamically appear on posts that have been dugg by readers (see example live post above). You can see an example of this pictured above and at the bottom of each post near the comment box. If you have a Digg account and somebody has already dug the post, then it will show the vote button and you can click it and send some love if you think the post is useful, interesting or entertaining. If somebody has not already dugg the post then it will show the “digg this” link. I have submitted a few posts in the past to digg myself, but it feels wrong submitting your own stuff, so I haven’t done it for a long while. I feel better asking readers to submit or vote on the posts they like. It helps the site, it helps me and in the end it will help you in the form of more posts of that type quality being produced in the future and made freely available.
If you’d like to have your own dynamic digg vote system and you are using Wordpress, it’s pretty easy to setup. Here’s what I did:
STEP 1. Downloaded the digg this plugin by Aviran Mordo.
STEP 2. opened the digg-this.php file at line 55, which is two lines above the function that reads:
function notify_moderator_on_digg($post_id, $digg_ref ) {
And add an else clause with the following code:
?>
<a href=”http://www.digg.com/submit?url=PERMALINK_URL&phase=2″ title=”digg this post”>digg it!</a>
<?php
}
Replace PERMALINK_URL with the permalink to your post. You can probably use something like: the_permalink();
STEP 3. FTP the modified digg-this.php file to your wp-content/plugins directory and activate.
STEP 4. Find a spot in either single.php or comments.php Wordpress template to add the digg_this_button code. It needs to be after the_loop part of the code so that you can get the correct permalink. You could hack it further of course if you wanted to use in another template or page but that is beyond the scope of what I wanted to do here.
STEP 5. Visit a post that has already been submitted to digg. If you don’t have any posts than get someone to submit one of your posts or digg one of your best ones yourself. As soon as the post is live on digg, which is right after you submit it to digg, visit the post page on digg.com and click thru to your post permalink page. You should now see the button instead of the link to “digg this.” Voila, you now have a dynamic digg this / digg vote setup just like we have here at Hmm. I would make sure if you submit the post yourself that’s it
Related posts based on word count
Download related posts plugin by Mr. Wasabi.
The next plugin I wanted to add was for showing related posts based on the number of words in a post. I chose a cutoff of 250 words, but if you didn’t want to have a cutoff based on word count than you can just download and activate the related post plugin out of the box. If you want to only show the related posts based on the number of words, then follow my instructions in this post: How to add sphere it function based on number of words.

The concept is the same in that I only want to show related posts for posts with a certain number of words. I chose to put the related posts at the very end of posts over 250 words right aligned. Some of the related post results aren’t as good as I’d choose myself, but in many cases it is helpful. Hopefully this helps interested readers explore other similar posts from the growing archives.
Google AJAX search
For awhile I’ve been wanting to add a way to conveniently search Google from within the Hmm search page. Those who have used the Hmm search before will note that there was a noticeable empty space on the right side. Once upon a time I tried putting Yahoo search results there but I wasn’t happy with the overall relevancy.
I added a checkbox to the search page with Google? next to it and when checked will run the same search through Google video, local, web and news. The results are returned almost instantaneously. You can run additional searches in the Google box and through AJAX you’ll get the results returned on the same page.

Try it out with this vanity search pictured above. The URL window will share any dual search result parameters, so you can share these searches with others.
You can add Google AJAX search to your site by using the Google AJAX search API. The first thing is to get an API key from Google and then go into your search results template and add the code that is generated. In our search.php template I added some code to transfer whatever is in the search box if the ga=g query string is set. The code to modify from Google is as follows:
searchControl.execute(”<?php echo($s);?>”);
The $s variable contains the search results. I didn’t make the code two way as far as what is entered into Google AJAX search input will prefill the Hmm results. That might be an interesting mod for another day.
Also, a reminder while on the Hmm search that any keyword can be subscribed to via RSS. This way if you only want to read posts on a specific keyword(s) you can do that here. Just click on the orange XML button for the RSS feed URL to use on the Hmm search results page.
From RSS to web
With these three changes I’ve added the ability for readers to digg or vote on already dugg stories, display related posts based on the number of words in a post and integrated an AJAX-style Google search. Pretty cool stuff with minimal time involved thanks to code generously donated to the internet community at large. If you operate a Wordpress blog you might look at adding these or other features and functionality for your readers.
Those who read the site in RSS only — which we’ve always provided full text RSS, BTW — will not experience most of this new functionality. This kind of stuff can help drive folks out of their feedreaders and back to the web version of your blog, although that is something I only thought of while writing this post. My main reason for adding everything here was to enhance the site experience for both readers and myself.
Now, it’s my turn to ask which of these features/functions do you find useful, if any? Is there some other feature you’d like to see added to this blog?
Related Posts- How to add Sphere It function based on number of words in post
- [site news] added spellchecker (for comments) and stats page
- Feedburner CEO: Click outs in RSS going down
- Please don’t go Feedburner promo link crazy like this
- Hmm housekeeping [site news]
- Almost 4 years to reach 2,500 thumbs up pages on StumbleUpon



(3 votes, average: 4.33 out of 5)
[…] I originally wrote about how to use the Google SOAP API back on January 12, 2003, nearly six months before this blog was begun and in fact did use their AJAX Search API to enhance the search area of this blog recently. I didn’t use Brady’s more pejorative reference “bling” because in front end situations like the one used here I think the AJAX API currently works better. […]
Pingback by Google quietly backrooms SOAP API for AJAX Search API » Make You Go Hmm — December 19, 2006 @ 5:56 am PST