‘Sharing’ links in the WordPress Loop

While coding the theme for this site I decided I wanted to add some ‘share this’ type links at the bottom of the posts. I initially had a look around at some plugins but everything seems a bit overkill, and would require work to then strip it down stylistically to fit with everything else.

So, with a bit of fishing around, I opted to just simply use anchor links to the sites I wanted to use. With this code sitting inside the WordPress loop, you can use ‘the_title’ & ‘the_permalink’ template tags the display the correct information.

Share on Facebook:

1
<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>" title="Share this on Facebook" target="blank">Share on Facebook</a>

Share on Twitter:

1
<a href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>" title="Share this on Twitter" target="_blank">Share on Twitter</a>

Share via Email:

1
<a href="mailto:type%20email%20address%20here?subject=I%20wanted%20to%20share%20this%20post%20with%20you%20from%20<?php bloginfo('name'); ?>&body=<?php the_title(); ?> - <?php the_permalink(); ?>" title="Email this to a friend" target="_blank">Share via Email</a>

Add to Delicious:

1
<a href="http://delicious.com/post?url=<?php the_permalink();?>" title="Add this bookmark to Delicious" target="blank">Add to Delicious</a>

Let me know what you think, if this is useful or if it can be improved.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">