Spread your Content on Twitter With Easy Retweet Button

John Resig is sharing very functional script named Easy Retweet Button that will simplify “the sharing of your content on Twitter“.

It is an unobtrusive JavaScript file for displaying a retweet link with a shortened URL via Bit.ly (similar to Tweetmeme) & number of clicks came to that content from Twitter.

Easy Retweet Button

Easy Retweet Button has 2 ready-to-go styles: vertical & horizontal. And it can be easily themed as only HTML, CSS & JavaScript is used.

It is possible to customize the “Retweet” text, prefix of the tweets (like RT @..) & Bit.ly username / API key to be used.

It offers various advantages like:

  • speed: it works completely asynchronously
  • tracking: all the tracking is done via Bit.ly & clicks from retweets can be tracked from a single interface

Steps For Using It With WordPress:

This is nothing complicated but can save your time:

  • Create a “js” folder in your active theme & upload Retweet.js into this folder
  • Include the Retweet.js to your theme. There are 2 options:
    • You may want to use retweet links only inside your post details (single.php) page. So, it is a better decision to include Retweet.js only into single.php to prevent unnecessary loading. In your template’s folder>header.php>between your head tags:
      if ( is_single()) {
      <script src="<?php bloginfo(’stylesheet_directory’); ?>/js/retweet.js"></script>
    • If you will use it site-wide (your homepage, post details, etc..) simple include the JS file to your template’s folder>header.php>between your head tags:
      <script src="<?php bloginfo('stylesheet_directory'); ?>/js/retweet.js"></script>
  • For using it inside post details (single.php), insert the code below to any part of your template’s single.php file:
    <a href="<?php echo get_permalink(); ?>" rel="nofollow"><?php the_title(); ?></a> . Besides the original examples of Easy Retweet Button, rel=nofollow info is added considering the link has no value to search engines.
  • And, you may want to get a free account from Bit.ly & update the username & API key info inside Retweet.js to reach your stats from a single interface.

Requirements: No Requirements
Compatibility: All Major Browsers
Website: http://ejohn.org/blog/retweet/

Leave a Comment.