05
2008
16:54 pm
Now when we have learned how to customize your count for RSS and Digg it’s time to learn how to do it for del.icio.us like I’m using on my themes page for example. As del.icio.us is in top 3 you just have to have it for bookmarking services because it usually gives most of the traffic right after StumbleUpon.

To make your count into plain text (for now and then you can do with it what ever you want) we’ll use small JavaScript and del.icio.us JSON feeds (read more about it here). You can see all kind of other services in your del.icio.us. setting account (for example network badges etc). So, let’s start with the code.
Since you are probably going to use this with WordPress i’ll be using it for example too. So to bookmark something to del.icio.us you are using code similar to this:
<a href=”http://del.icio.us/post?url=<?php echo get_permalink() ?>& amp;title=<?php the_title(); ?>”> save to del.icio.us </a>
Now where you want to have the count add this line (i have added it in span next to link) and just past this JavaScript under it and you’re done
<span id=’<?php echo md5(”http://”.$_SERVER[”HTTP_HOST”].$_SERVER[”REQUEST_URI”]);?>’>0</span>
<script type=’text/javascript’>
function displayURL(data) {
var urlinfo = data[0];
if (!urlinfo.total_posts) return;
document.getElementById(”<?php echo md5(”http://”.$_SERVER[”HTTP_HOST”].$_SERVER[”REQUEST_URI”]);?>”).innerHTML = urlinfo.total_posts;
}
</script>
<script src=’http://badges.del.icio.us/feeds/json/url/data?url=<?php the_permalink() ?>&callback=displayURL’></script>
Ruestions, problems? Post them here in comments
People need to be more aware that they *need* a syntax highlighting plugin, that will fix the curly quotes & stuff that WP puts everywhere.
I’ve been using iG Syntax Hilite for about 3 years now and it’s great.
Very nice…
I’ll probably end up using that for my next design…
May 10th
2008
21:23 pm
@ James
Yes, sorry about that WordPress does it
@ kremalicious
Well, it can work on index page but it doesn’t display count correctly, as you mentioned (starts from number two or something like that as i remember) and i don’t think i have a solution for it…
just to add: firebug and Safari’s Web Inspector display an error with this line:
if (!urlinfo.total_posts) return;
Nice quick and easy tutorial. but how to implement the correct number count on an index.php template with different posts on one page? in such a case the REQUEST_URI function will use the blog url and not the post url. is there a way to replace it with something like to get it to work on pages with more than one article?
Great little tip, I loved it. The only problem I had was the quotes ‘ and double quotes ” got a bit mixed up as I copied and pasted. I just had to go through an change that bit of code.
May 10th
2008
16:58 pm
nice and easy ![]()





Enteries RSS (1021) 
del.icio.us (
StumbleUpon
Digg
Wong it
9 Responses,
Ezkzoddg:
May 13th
2008
11:40 am
No doubt, this is really great. Thanks for sharing