WordPress: The Best Tweet This Link Ever

With the right people sharing your blog entries on Twitter, you’ll receive a good amount of quality referrals. One way this occurs is a retweet from frequently retweeted people as seen here.

The other way is to make it super simple for readers to tweet your blog entry. That’s where this post helps. If you have a self-hosted WordPress blog, add this code to your /wp-content/themes/[current theme]/single.php file where you want your own “Tweet This” link. [TinyURL shortening code originally from here]

1
2
3
4
5
<?php
$shortenedurl = file_get_contents('http://tinyurl.com/api-create.php?url=' . urlencode(get_permalink()));
?>
 
<a href="http://www.twitter.com/home?status=<?php echo str_replace(' ', '+', the_title_attribute('echo=0')); echo '+' . $shortenedurl; ?>" title="Share <?php the_title_attribute(); ?> on Twitter">Tweet This</a>

Published March 20, 2009. Tagged: , , . Read it later with Instapaper

All original content is © Brian Cray. I reserve all rights unless otherwise stated. Request permission to reuse content through Twitter