Add to Delicious Plugin

Download plugin: Add To Del.icio.us — Version 1.0 (Oct 12, 2006)

Having recently overhauled the website and converting to WordPress, I prefer to find plugins for whatever it is that I need and take the path of least resistance. I wanted a plugin that would simply add an “add to del.icio.us” link to my posts and found a plugin but it turned out that the plugin used the title of the blog rather than the post title for posting to del.icio.us. I set off to hack but saw the code was nearly a 100 lines and used JavaScript which is totally unresourceful. Just to experiment I wrote a plugin and turns out it only takes three lines for the plugin:

function delicious_link($linktext = 'add to del.icio.us') {
	global $post;
	if ($post) {
		echo '<a href="http://del.icio.us/post?url='.$post->guid.'&title='.$post->post_title.'">'.$linktext.'</a>';
	}
}

Install

To insert a link to delicious you simply need to download the plugin file, unzip the add-to-delicious.php file and upload it to your wp-content/plugins folder. Activate the plugin from WordPress administration and add the following code inside the while loop:

<?php delicious_link(); ?>

which will output a link with text add to del.icio.us. Alternately, you can pass in your own link text if you want:

<?php delicious_link('add this page to del.icio.us'); ?>

In case you are wondering, the while loop is in your themes folder and starts off like this:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

This plugin is so trivial I am not sure why I’m posting it but someone will probably find this useful anyway. For what it’s worth you can just add the following in your While loop and not have to use the plugin:

Post to: <a href="http://del.icio.us/post?url=del.icio.us</a>

Add this page to del.icio.us