WordPress: The Best Tweet This Link Ever

Posted March 20, 2009 by Brian Cray

Reading time: About 0 minutes

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>

About the author

Photo of Brian Cray

Brian Cray is a Columbus, Ohio-based web entrepreneur & consultant. View some of Brian’s work in his portfolio and learn how to make kick ass websites by reading his blog.

8 Article comments

Show/add comments

1 Article references from other blogs

Show all references

274
Previous:
Next: