Twitter is all the rage these days and it doesn’t seem like it will be going anywhere any time soon.  With that said, it often surprises me that many WordPress blog owners  don’t offer a convenient way for their readers to retweet their content.  Anyone can grab a Twitter WordPress plugin to tweet their new content as it is published, but what about your older content?

Rather than passing up all that potential traffic, I’ve found that offering a link somewhere within your post (optimally at the bottom of each post) is a great way to help your readers and incoming search engine traffic to promote your content for you.  When people find great content they like to share it with others, so why not make it easy for them?

Not only is adding a “Tweet This!” link a great choice, but it is really easy to do.  Chances are if you do a search on Google for code to use you’ll find something like the following:

<a href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>" title="Click to send this page to Twitter!" target="_blank">Tweet This!</a>

This code works just fine, but is not the most optimal solution in my opinion.  Depending on the permalink structure your WordPress blog uses, combined with the length of your domain name, it may be difficult to fit the link into a 140 character tweet.  It also doesn’t leave room for the person to add their own comments to the tweet.

As a proposed solution, I recommend using some WordPress code like the following:

<a href="http://twitter.com/home?status=RT @HackWordPress <?php the_title ();?> <?php echo get_settings('home'); ?>/?p=<?php the_ID(); ?>">Tweet This</a>

This code will automatically insert the “RT” and your Twitter account name (the above example uses our Twitter account, @HackWordPress) then use the ID form of your post with the tweet.  When people click the link in the tweet, they will then be redirected to the actual post using your blog’s selected permalink structure, making a convenient and typically short URL.

Have you integrated Twitter into your WordPress blog? Share your strategies in the comments!

Want automatic updates? Subscribe to our RSS feed or
Get Email Updates sent directly to your inbox!
Tweet This | Digg This | Stumble it | Add to Del.icio.us | | Print This

Kyle Eslick

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level back in 2007 by launching WPHacks.com as a place to share hacks and review WordPress-related products. You can learn more about him by following his personal tweets here.

There Are 11 Responses So Far »

  1. Mike says:

    Seems nice idea and can be tried, right now i used http://tweetmeme.com plugin and keeps increasing one by one whenever any one retweet the posts

  2. I’m using both TweetMeme and my own “tweet this” snippet of PHP code very similar to your solution, Kyle.

    <a rel="external nofollow" href="http://twitter.com/home?&status=Reading: @iBizAcademy blog post http://iBizAcademy.com/?p=ID ?>”>Tweet it

    This can also be viewed here: http://ibizacademy.com/img/tweet-this.txt

    Another reason I opted to use the post ID, instead of the full URL, is that way it acts as a kind of URL shortener, while still giving me the most Google juice. Besides, think about a possible scenario: Bit.ly and Co. go out of business and all your shortened links are dead.

    Looking forward to more great tips from you!

  3. Luis says:

    I was having problems with other code snippets, I think because I’m on WordPress MU. Your solution worked awesomely with my site, hope this help others.

  4. This has really got me thinking. Thanks for that. I am really looking forward to revisiting this site :)

  5. Jack says:

    I tried to add this to a blog post of mine on the British Pathe blog – http://www.britishpathe.wordpress.com – but it didn’t work. The code just shows up within the blog post.

    You haven’t said where to put this code and how to make it work?? Sorry if this site is for experts who already know these things.

    Thanks,

    Jack

    • Kyle Eslick says:

      Hi Jack,

      I apologize if the post wasn’t clear. Truth is, it can be placed wherever you want it to display on your website!

      It sounds like you may be placing it within the post loop instead of above or below it, although this can vary greatly based upon how your theme was designed. Try placing it above or below the div that has “the_content”, not within the div. That should hopefully help.

  6. Emilio Breed says:

    Cheers for making this post. Could prove to be useful to me.

  7. Cool tips. I already add it into my site and change it into my twit account. My question is now, do you have any button for change the ‘tweet this’ text?

    Thank you. :D

  8. sam says:

    Very nice HTML work actually HTML work is mainly for the blogger. very good information how to add a twitter link to yahoo meme..thanks for providing..

Trackbacks/Pingbacks »

Tweetbacks »

Leave a Reply