Amazon.com Widgets

WordPress Plugin: Filtered Twitter

October 19, 2008

4 Dec 2008 The download link for this plugin has been fixed. Thanks to eagle-eyed reader Liam for alerting me to the problem!

Those of you who follow me on Twitter know that I use twitterfeed to auto-tweet new blog posts and new delicious bookmarks.

I wanted a way to display my latest tweet on the front page of my blog, but to exclude those auto-tweets (since anyone viewing the blog can see my delicious links and, obviously, my blog posts). I searched high and low for a plugin that would filter my incoming tweets, to no avail. Either my search skills are rusty or no such animal exists.

Then I realized that, since Twitter now offers search, I could get it to do all the heavy lifting for me. Enter my latest quick-and-dirty WordPress plugin, Filtered Twitter.

Description

Filtered Twitter is a twitter-oriented RSS parser for displaying feeds generated by search.twitter.com.

Installation

  1. Download and unzip filteredtwitter.zip
  2. Upload filteredTwitter.php to your plugins directory (wp-content/plugins/)
  3. Activate the plugin in your WordPress Dashboard

Usage

You now have access to a new template tag, which takes the following parameters: filteredTwitter($twitterFeed, $timeZone, $maxTweets, $showDate, $linkDate)

  1. Using Twitter Search, craft your personalized Twitter feed
  2. Copy the URI of your search feed (found on the right side of the search results page)
  3. Insert the Filtered Twitter tag into your WordPress template:
    • $twitterFeed:The feed URI is the only required parameter
    • $timeZone: Between Twitter using GMT for its feed timestamps and PHP wonkiness, you might have to play with this a little to get it right. By default, the setting is '-4', which gives the correct time for the East Coast of the US (update: Daylight Savings screws this up, so you'll have to manually tweak this twice a year, or until I sort it out).
    • $maxTweets: By default, only one tweet is displayed. Change this to any positive integer to suit your tastes.
    • $showDate: Set to true by default; change to false if you prefer not to show the tweet time
    • $linkDate: Turns the tweet time into a link to the tweet on Twitter. Set to true by default.

Example Usage

So on my blog, I wanted to exclude tweets that contain the hashtags #blog and #delicious. I set up the Twitter search like so:

The search results gave me the following atom feed: http://search.twitter.com/search.atom?q=++-%23blog+-%23delicious+from%3AGoBecky

So to show my latest tweet, excluding the auto-tweet, I inserted the following code into my WordPress blog: filteredTwitter('http://search.twitter.com/search.atom?q=++-%23blog+-%23delicious+from%3AGoBecky')

Notes

This plugin is pretty rough, with no error handling. If it causes problems for you, just leave me a comment and I'll see what I can do to help you.

{ 1 trackback }

Top 25 twitter tools for Wordpress | honeytech
11.18.08 at 6:46 am

Comments on this entry are closed.

Previous post: More: Trig Palin as Political Prop

Next post: Gen. Colin Powell Endorses Barack Obama for President