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!

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Connect with Kyle on Twitter or Google+!

  • http://www.searchengineoptimization.co.uk Mike

    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

    • http://www.deluxeblogtips.com Deluxe Blog Tips

      Yes, I’d like to use Tweetmeme in websites. But it may cause to load many javascript file, so the method described here is another solution.

      PS: I’d like to use the shortlink of post instead of its permalink: http://domain.com/?p=id

    • http://allyspotts.com Ally

      Thanks for the advice, Mike! I just installed the TweetMeme plug-in to my wordpress site. If I had know it was so easy, I would have done it months ago.

  • http://iBizAcademy.com Boris Mahovac

    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!

    • jurug

      thanks for code… I have copies this code :D

  • http://lwees.com Luis

    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.

  • Alexandra Mizenko

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

  • Pingback: How To: Add a Twitter Link to Your WordPress Blog | Wordpress Blog Hosting

  • http://www.britishpathe.com Jack

    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

    • http://kyleeslick.com Kyle Eslick

      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.

  • http://www.blogger.com/profile/03703432069478755637 Emilio Breed

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

  • William M. Felix

    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

  • Pingback: TECHFLAPS - Waves of Technology | 10 Extremely Useful Wordpress Hacks

  • http://www.indiaseo.com sam

    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..

  • Deepanshu

    well it works but it only gives a simple text stating tweet this without displaying any button which doesnt look nice :-( how to insert a button….i managed it for fb like button using this code :-)

    <iframe src="http://www.facebook.com/plugins/like.php?href=ID)); ?>&layout=standard&show_faces=true&width=450&action=like&colorscheme=light” scrolling=”no” frameborder=”0″ allowTransparency=”true” style=”border:none; overflow:hidden; width:450px; height:60px;”>

    how can i do it for twitter….i would love to get rid of another plugin :roll:

    figured out :-)

    <a href="http://twitter.com/share?url=ID)); ?>&via=crackentrance&count=horizontal” class=”twitter-share-button”>Tweet

    edit :

    <a href="http://twitter.com/share?url=ID)); ?>&via=crackentrance&count=horizontal” class=”twitter-share-button”>Tweet

  • Oris WilliamsF1

    it works but it only gives a simple text stating tweet this without displaying any button which doesnt look nice how to insert a button….i managed it for fb like button using this code

  • Nick

    Thank you Kuldeep, I understood the code and I have used it on my site too!
    Brilliant work keep it up.