Currently the method being adopted by many web masters to display tweets on their web sites does not support retweets (RT). Recently there was an update to allow the parameter include_rts=true to be inluded within the url used to retrieve the tweets but unfortunately this is not compatible with Blogger.js as it only effects the .rss and .atom feeds (and not the .json feed).

We have now released a word press plugin that resolves this issue and enables you to easily replace the code you might currently be using with a single line change that will add retweets to your pages.

This update also enables you to include a twitter feed with your wordpress blogs because the same <ul id="?"/> tag will add a twitter feed anywhere it is placed within your entire site.

Download Here

The Details

If you have followed the advice in one of the many blogs on the internet that instruct you how to add twitter feeds to your site then you have probably already added a <ul id="twitter_update_list"></ul> element to your pages, along with two javascript includes:

<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>`
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/[yourUsername].json?callback=twitterCallback2&amp;count=10"></script>

This approach retrieves your tweets using the twitter .json feed which calls a method called twitterCallback2 in
blogger.js that then inserts your tweets into the <ul /> element hat has the “twitter_update_list”.

The problem here is that the .json feed does not currently return retweets. When you start looking around for a solution
to this you will notice that twitter responded to this problem by introducing an include_rts=true parameter which is supposed to add retweets to their feed.

Unfortunatly, after some research it seems that the include_rts parameter is only supported by the .rss and .atom feeds i.e. http://twitter.com/statuses/user_timeline/[yourUsername].atom and to make matters worse you cannot simply replace the url used in the second of the script includes above to use the .atom or .rss urls because the output from these urls is not recognised by the code in blogger.js.

Our new plugin uses a service provided by google to convert the .atom feed into a JSON object which is then used with code
borrowed from blogger.js to insert the tweets, including the retweets to your <ul id="twitter_feed_list"/> element.

We have also given you the ability to put multiple feeds on a single page by allowing you to name the element that will recieve them (see FAQ’s). Also, by implementing the code in the footer.php file as instructed anywhere you add the <ul /> tag the feed will appear. This means that if you use <ul id="myFeeds"></ul> to add a feed to your home page, you can also add the same feed to any blog or page by adding the same <ul id="myFeeds"></ul> line on those pages.

Installation

You can either install it automatically from the WordPress admin, or do it manually:

  • Upload the whole `twitter-rss-with-rt` directory into your plugins /wp-content/plugins/
  • Activate the plugin through the ‘Plugins’ menu in WordPress

Once installed take the following steps to set it up:

  • Open /wp-content/themes/[yourTheme]/footer.php in a text editor
  • Locate the bottom of footer.php just before </body>]]>
  • Insert the following line:
    < ?php get_tweets_with_rt('[your_twitter_username]', [number_of_tweets], '[control_id]'); ?>
  • If you have the following included the following scripts in your code then remove them:
    <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
    <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/[yourUsername].json?callback=twitterCallback2"></script>
  • Ensure you have placed <ul id="[elementId]"></ul> where you want your feeds to appear eg <ul id="twitter_update_list"></ul>.

If you have already followed other blogs and included the two script files mentioned above you may already have this <ul> element in your code.

i.e.

<html>
   <head></head>
   <body>
      ...
      <ul id="maraboustork_tweets"></ul>
      ...
      < ?php get_tweets_with_rt('maraboustorkltd', 10, 'maraboustork_tweets'); ?>
   </body>
</html>

Frequently Asked Questions

How do I change the appearance of these tweets?

You can control their appearance in the normal way using css. Below is an example that will give you the appearance used at http://maraboustork.co.uk.

#twitter_update_list {
   float: left;
   margin-right: 20px;
   width: 280px;
   font-size: 10px;
}
 
#twitter_update_list li {
   border-bottom: 1px dotted #E6E6E6;
   list-style-type: none;
   padding: 10px 0px;
}

If you have renamed your <ul> element then ensure that that name is also changed in the above css.

How can I add more than 1 feed to my page?

Simply add an additional call to the PHP procedure in your markup:

< ?php get_tweets_with_rt('[your_twitter_username]', [number_of_tweets], '[control_id]'); ?>

i.e.

<html>
   <head></head>
   <body>
      ...
      <ul id="maraboustork_tweets"></ul>
      <ul id="some_other_feed"></ul>
      ...
      < ?php get_tweets_with_rt('maraboustorkltd', 10, 'maraboustork_tweets'); ?>
      < ?php get_tweets_with_rt('someothertwitteraccount', 5, 'some_other_feed'); ?>
   </body>
</html>

Why are my tweets are not appearing?

We have noticed that there is a slight delay between the initial call our code makes to the google api and receiving he tweets. We are in contact with them about this as it appears that it is a security function to prevent you from carrying out a denial of service attack against a feed provider using the google api as a proxy to that attack (although we are waiting for this to be confirmed).

We recommend you check that you have specified your twitter user details correctly by accessing the following url in your web browser:

http://twitter.com/statuses/user_timeline/[Your Twitter Username].atom?count=10&include_rts=true

If your tweets are returned in an xml format then there is no reason why the plugin will not work, and we therefore recommend that you wait for 10-15 minutes and try refreshing your pages after this period.

Credits

* Some js used from http://twitter.com/javascripts/blogger.js
* Google API’s http://ajax.googleapis.com/ajax/services/feed
* Anyone who has blogged about the problems with displaying RT’s

Tags: , , , , , , , , , , , ,

6 Responses to “WordPress plugin to add RTs to your Twitter feed.”

  1. C#Cowboy October 11, 2010 at 10:27 pm #

    Built an auto-retweet bot using StoreCrows blog found at http://storecrowd.com/blog/retweet-bot

  2. quinny kinderwagen October 25, 2010 at 10:35 am #

    Please, can you PM me and tell me few more thinks about this, I am really fan of your blog…gets solved properly asap.

  3. branchenverzeichnis October 26, 2010 at 6:17 am #

    There is obviously a lot to know about this. I think you made some good points in Features also.
    Keep working ,great job!

  4. potenzmittel October 31, 2010 at 11:23 am #

    There is obviously a lot to know about this. I think you made some good points in Features also.
    Keep working ,great job!

  5. sichere geldanlage 2011 October 31, 2010 at 1:47 pm #

    Of course, what a great site and informative posts, I will add backlink – bookmark this site? Regards,
    Reader.

  6. webseiten erstellen November 1, 2010 at 6:36 pm #

    Hey very nice blog!! Man .. Beautiful .. Amazing .. I will bookmark your blog and take the feeds
    also…

Leave a Reply