Display how many times a wordpress post has been saved to Delicious

December 1, 2008 · Print This Article

Are your blog posts popular?

A good way to know it and take advantage of it is to display your Delicious.com save count. Sure, they provide a badge which allows you and your readers to know how many time your post was saved. In my opinion, the badge is ugly. Let’s display our save count in plain text.

To get your Delicious save count in plain text, simply open the single.php file from your theme and paste the following code where you’d like the count to be displayed.

Delicous.com saves: <span id='del'>0</span>

<script type='text/javascript'>
function displayURL(data) {
var urlinfo = data[0];
if (!urlinfo.total_posts) return;
document.getElementById("del").innerHTML = urlinfo.total_posts;
}
</script>

<script src='http://badges.del.icio.us/feeds/json/url/data?url=<?php the_permalink() ?>&callback=displayURL'></script>

Getting our Delicious save count isn’t hard at all. On this exemple, I have created a html element with a specific id and then imported a script from delicious. Once the script is loaded, I executed a function to replace the initial zero with the current number of saves for the specific item.


Your choice for site templates and wordpress themes

Comments

Got something to say?

You must be logged in to post a comment.