Custom Web Design Project Management Login

Newsletter Management Login

Back to CHROMATIC's Blog Home Page

Looking for a more simplistic solution to posting custom Twitter ReTweet (RT) links on your WordPress blog posts? Twitter ReTweet is the answer.

WordPress Plugin: Twitter ReTweet Image
Delicious Save to Delicious

WordPress Plugin: Twitter ReTweet

Posted by: Matt 43 comments

I spent the last few hours scouring the net, searching for a WordPress plugin that we could use to output a basic, stylable link anywhere on a WordPress post or page which, when clicked, would allow our visitors to quickly and easily ReTweet (RT) the current post.

There was one catch, though: we needed to be able to use and encode ReTweetable custom URLs, mainly because we utilize Google Analytic’s useful Campaign Tracking feature which assists us in monitoring website traffic that doesn’t have a referrer (for example, links that are clicked in external Twitter applications or external e-mail apps are normally recorded as “(direct)” traffic).

Currently, there is a WordPress ReTweet plugin option available called TweetSuite, however, there are a few things that we don’t quite like about this plugin:

  1. We don’t want the ReTweets to be displayed within the post content area
  2. We need the ReTweet link to appear outside of the post content area, specifically, in our calls to action box
  3. Since the plugin is still in beta, we don’t want to deal with possible spam issues (especially since we’ve been spoiled with WP-SpamFree)
  4. Most importantly, we need the ability to encode URLs with custom query parameters and then encode those URLs into a format suitable for micro-blogging (tinyurl.com, for example)

That’s not to say that I don’t think that the developer of TweetSuite is on to something great. With a little work, the plugin will be much more useful to a greater number of Twitter users – including us.

In the meantime, I’ve created a simple WordPress plugin which gives you the ability to output a simple, styable link anywhere within a WordPress post/page. Please keep in mind that, since Twitter ReTweet “ReTweets” a WordPress post, this plugin assumes that you post an initial tweet which contains a link to the newly published post on your blog. After all, people aren’t really “ReTweeting” unless there is that initial tweet.

Usage

This plugin is really easy to use. There are a few simple steps that must be taken prior to installing the plugin:

  1. Twitter ReTweet User Profile Nickname FieldFill in the Profile (“/wp-admin/profile.php”) field “Nickname” with your Twitter username. This allows us to bypass any custom database modifications. Hey, it’s there – why not use it?
  2. Twitter ReTweet Custom FieldEach post that you would like to utilize the custom ReTweet link must have a “custom field” called retweet_url. Here is some helpful documentation on using WordPress custom fields. It is through the use of this custom field that we are able to dynamically pull the encoded URL related to each post. If you don’t fill in this custom field for a post, then the ReTweet link will be absent from that post and the plugin will degrade without a hitch.
  3. If you’d like to style the link (perhaps you want to use a CSS image rollover instead of a plain Jane link), the CSS class is reTweetPost.

Once you’ve completed the aforementioned steps, follow these step by step instructions to activate the plugin:

  1. Download Twitter ReTweet
  2. Extract the .zip file
  3. Move the “twitter-retweet” folder into your “wp-content/plugins” directory and upload to your remote server
  4. Login to your WordPress account
  5. Navigate to the “Plugins” section or go directly to “/wp-admin/plugins.php”
  6. Activate the “Twitter ReTweet” plugin
  7. Copy and paste the following code into the desired template(s) (we use the single.php template); the code should be placed within the WordPress loop:
    <?php if(function_exists('twitterReTweet')) {
    	echo twitterReTweet();
    }?>
  8. Save and upload the modified template file(s)
  9. If you’ve done everything correctly, then you should see the ReTweet link on the pages/posts that have the “retweet_url” custom field filled in. The link, when clicked, will fill the following information into the visitor’s Twitter.com status box (they will need to click the “Update” button to post it): “RT @username: Post Title – hyperlink“. Our real world example is located beneath the author box of this post.

Twitter/E-mail Campaign Tracking

As stated above, the primary reason we wrote this plugin is because we needed to use Google Analytic’s Campaign Tracking feature within our URLs. In addition, we needed to convert those long, Twitter-inappropriate links into short links suitable for micro-blogging. This plugin gives you the ability to track whichever pages/posts you’d like, while at the same time allows you to use whatever kind of custom tracking you’d like to use (you don’t have to use Google Analytics, and you don’t have to use TinyURL!). Best of all, you can place this link anywhere, and since we’re using a class for the link, you can repeat it on the page/post as many times as you’d like without affecting your XHTML validation.

Available on WordPress.org

Twitter ReTweet has been accepted into the WordPress.org Plugin Directory. For more information about the plugin, visit the Twitter ReTweet plugin page.

Download this Plugin » | Learn more about Twitter » | Learn more about GA Campaign Tracking »

About the Author...

Matt is the Director of Operations at CHROMATIC. He is really intrigued by all aspects of the web, business, and everything in between. Matt has been told that he has a sometimes unhealthy passion for going above and beyond to over-deliver for clients. That's just who he is, though. He's big on Macs, music, the outdoors, and long, spontaneous road trips.

Like this post? What next?
Comments for this postComments are directly below (arrow image)

Leave a Comment

  1. It’s easy to adapt Dan’s plugin to display tweetbacks (or anything else) from his plugin on the desired place. Simply comment out the “addfilter .. addTweetbacks” line (about line #26) and add <?= addTweetBacks(); ?> in your template, at desired spot. That’s all :D

    • Hi Ton?i. That part may be easy, however, not everyone has the experience to get inside of a plugin and edit the source. In addition, the main reason why we made this plugin was because we needed to be able to edit the ReTweet link URL, rather than have it use an auto-generated URL (for customized campaign tracking).

  2. This plugin looks pretty nice and clean for the purpose. I like a lot where you place it in your own post, alongside the sharing and rss links.
    Well done, plan to implement it myself soon.

    • Thanks a lot, Palmamod. Yes, it is clean and simple by nature, but it was made to not get in the way, not slow down page loads, and to provide a simple and very useful purpose. I hope you find it useful!

  3. thanks for the detailed explanation Matt,now i will go ahead to implement it for my personal site

  4. hi. Thanks for plugin

    perfect.

    Regards

  5. I like this plugin BUT am more intrigued by your ‘postcard’ with the ShareIt, ReTweet, Subscribe buttons WHERE THEY CAN BE SEEN! How you do that?

    • Hi Bart. I’m not sure I understand your question. If you care to rephrase it, I will happily answer.

  6. Below your post you have the ‘What’s Next’ card with buttons for “Save or Share”, ReTweet, or Subscribe (which I have done).

    What I would like to do on my blog, http://www.mentalmeals.com, is create an area a bit like yours, after each post, so that it is obvious to the readers what they can do with the post – Share-It, Print It, ReTweet, etc.

    I am not timid about cutting and pasting code into php files, etc., but I don’t know how to make these options stand out on my blog(s)

    • Ton?i, thanks for the clarification! :)

      Bart, Ton?i is exactly right. That is a custom design that we created from scratch. You can’t download it anywhere, but instead, you must create it on your own. The good news is, it’s really not too difficult to create. If you have some design experience, know a little bit about CSS, and have some basic experience with XHTML and PHP, you should be able to replicate (without copying of course!) what we accomplished.

      But yes, Ton?i is right that you can also just download the plugins that he cited in his response to you. Although it’s not as custom, it does provide similar functionality.

  7. @Matt: (I think) Bart means the div with id postWhatsNext ;)
    @Bart: I don’t think it’s a plugin, rather a custom template design, plugins that provide similar functionality can be found here: http://wordpress.org/extend/plugins/share-this/ and http://wordpress.org/extend/plugins/sociable/

  8. Thank you both, Matt and Tonci. I will look into this. I thoroughly believe a call to action that stands out will generate more interest.

  9. matt, how can I add class to the retweet link?

    is this the correct place?

    • Hi Louis. The class name is “reTweetPost”. It’s already integrated into the plugin, so just use your CSS stylesheet to style the output using that class.

      • Michael August 14, 2009

        Hi Matt,

        Thanks for the neat plugin! About the CSS class though, I actually don’t see it anywhere in the file. When I extract it, all I get is a twitter-retweet.php file, and there’s no mention of the CSS class in there.

        Right now, the plugin displays the text “ReTweet This Post” with no formatting. Any ideas on how I can get the button to show?

        • Hi Michael. The CSS class is contained within the source code in the twitter-retweet.php file. You then need to reference that CSS class in a CSS file in order to style it.

          • Michael August 15, 2009

            Hi Matt,

            Thank you for your prompt response. I re-downloaded twitter-retweet.zip and checked out the .php file again, but I still don’t see the CSS class.

            Perhaps the CSS stuff got removed in an update? Maybe I downloaded the wrong file?

            Is there something else I should be doing?

            Thanks again,
            Michael

          • If anyone is having a problem getting this to work, please leave a comment and I will try my best to help.

  10. awesome! didn’t see that for some reason… got it working now. Thanks again.

  11. How do i edit the plugin so that it automatically picks up the current post title rather than having to enter is as a custom filed for every post?

    • Gadget – the current post title is automatically built-in to be displayed when someone clicks the “ReTweet” button. Are you referring to having it automatically insert the URL for each post?

      The reason why the plugin makes you enter in a custom URL is because the natural post URLs are not Twitter-friendly. Shortening the URL with a URL shortening service and then pasting that into the custom field is best practice, IMO.

      And again, the primary purpose of this plugin is to give you the ability to encode additional tracking parameters so that you can track the link clicks in Twitter using Google’s “Campaigns” feature. Read above for more details.

  12. Hey Matt, thanks for the plugin dude.

    I got a problem though. I have followed everything to the letter, and i don’t see a link to the retweet on my posts.

    Can you help?

    I’m using 2.7.1 and using the Revolution News 4.0 theme (link is hyperlinked to my name here) thanks.

    Loz

  13. I’d rather not enter a custom field on each post but instead have the re-tweet facility to appear on every post. Is this easy to achieve?

    Thanks,

    Paul

    • Hi Paul – this sort of defeats the purpose of this plugin, however, if you want to edit the plugin source file on your own, this can be accomplished. The problem is, without a custom field, how will the ReTweet plugin know which link to use for each post unless of course you’re outputting the entire URL instead of a compacted URL? This isn’t micro-blogging-friendly, though.

  14. Works perfect, just one question… How would I change the username?
    For example, if I click the ReTweet link it would show RT @Benny. But my twitter username is benny11k… So it takes the Benny off of my WordPress account, how can I change that?

    • Benny, that step should be included in the above instructions. There is a field that you need to modify within your WordPress User Profile which should contain your Twitter user name.

  15. Nvm. :P
    I got it anyway, simply in the PHP you just had to change:

    the_author_nickname();
    to:
    echo ‘benny11k’;

  16. I decided to change things up, because I couldn’t figure out how to make it work.

    However, there seems to be another issue … Twitter just did some site maintenance and now the ReTweet plugin doesn’t populate the tweet box when you’re redirected to Twitter. Click on the ReTweet button above to see what I’m talking about.

    … Scott

    • Scott, I can’t seem to duplicate the issue you are having. Even after the latest batch of Twitter.com updates, the box is populating for me without a problem.

  17. That’s weird … I too see that it works in Firefox and Safari, I have been using Flock and it’s not working in Flock, not sure why.

    I restarted the browser, but I’ll try clearing the cache and restarting the computer to see if that resolves it.

    Thanks for the reply … Scott

  18. Hi Matt, thanks a lot for your plugin, it just does what it should without bells and whistles.
    With a little css customization, it got it looking the way I want it.

    Keep up the good work
    Filipe

  19. Hi,
    When I click on the button I am getting the following…

    RT @myNickname myDomain » Blog Archive » postTitle http://bit.ly/xXxX (via @tweetmeme)

    How can I remove “myDomain » Blog Archive »”?

    • Hi Eric. I think you’re confusing the tweetmeme plugin with the plugin I created. Scroll down (right above where the comments begin) and click on that ReTweet button. That is the plugin that I created. We’re actually using two Twitter ReTweet plugins on the site now: the one at the top with the ReTweet counter is the tweetmeme plugin; the one above the comments is my Twitter ReTweet plugin which is much more simpler in concept.

  20. I see that you have a tweet button at the top and one at the bottom of your page, which one uses your plugin? I like that the one at the top of the page counts the re-tweets and that it is integrated with digg and stumbleupon.

    While I’m asking, what plug is at the bottom of your page beside the retweet, the “save it or share it” one?

    Thanks,
    Tim

  21. Hi Matt,
    Thanks for this great plugin. Like Scott Prock and Loz, I’m having trouble making it work after following your directions by the letter. Any chance you guys have it working already?

    Safari 4.0.3

  22. Great idea but when I tried installing it on one of my blogs it didn’t seem to do anything, it’s listed in the plugins section and is activated but I couldn’t find an option for configuring the settings :-(

  23. Ok, I’m having some trouble getting started altogether because I can’t find the wp-admin/profile.php in my files. what if I don’t have access to this? Help!

    • Vania, you do not physically navigate to this file. Instead, navigate to your blog’s home page in a web browser, and then add “/wp-admin/profile.php” to the end of the address. Assuming that you’re logged in, this will take you to the profile page located within the WordPress admin section.

  24. Hey Matt,
    Thanks for the prompt response. Finally got it. So I’d have to make my own image, right? That’s cool.

    Thanks again for your help.

  25. If you are using a custom write panel (tut: http://wefunction.com/2008/10/tutorial-creating-custom-write-panels-in-wordpress/) then you need to change the source code on line 16 from:

    $retweetURL = get_post_meta($post->ID, “retweet_url”, true);

    to

    $retweetURL = get_post_meta($post->ID, “retweet_url_value”, true);

  26. I’ll try it later. Thanks for plugin. I just hope it works as I have been updated to the latest version of wp.

  27. Hey Matt,

    Thank You for the heads up about your re-tweet plug-in.

    So I take it as, if we already tweeted our blog post to twitter then your plug-in will retweet the same url even if it’s a su.pr URL and we can configure the CSS to have an image hoover instead of a text link.

    Now that’s just Cool!

    Thanks Again
    Steve Fisher

  28. This is a cool plugin. thanks a lot for sharing this.

    -Deepu

Leave a comment for this post

  • Please keep comments related to topic. Whatever you do, don't spam!
  • Basic HTML tags are allowed:
    <a href> <abbr> <acronym> <blockquote> <code> <em> <strike> <strong>
  • Note: un-related or spam comments will be deleted. Also, we use the rel=nofollow tag, so there's even less of a reason to spam.

Trackback this postComments are directly below (arrow image)

Trackback this post

  1. March 28, 2009
  2. March 30, 2009
  3. June 14, 2009
  4. August 11, 2009
  5. August 19, 2009
  6. August 20, 2009
  7. September 5, 2009
  8. September 19, 2009
  9. September 24, 2009
  10. September 26, 2009
  11. November 20, 2009
  12. January 13, 2010
  13. February 9, 2010
  14. March 6, 2010
  15. March 16, 2010
  16. March 25, 2010
Back to top