April 14th, 2008 Wordpress Twitter Widget
My latest plugin is a sidebar widget that handles Twitter feeds. It’s true that you could just point and RSS widget at one of the Twitter feeds, but you end up with the whole tweet (I honestly don’t know what they are called) as a link, @replies don’t function, etc. Twitter Widget Pro properly handles twitter feeds, including @username and link parsing, feeds that include friends or just one user, and can even display profile images for the users. It’s set up like the RSS widgets, so you can have as many of as you want on your sidebars.
I currently have my twitter feed in the right sidebar, showing the last five tweets, and Kevin Rose’s feed (with friends) in the left sidebar, showing profile images along with each of the last 10 tweets.
I tried to make everything easily styled, so there are no built-in styles. If you don’t know exactly what you need, here is what I’m using on this site:
/** * Twitter Widget */ .widget_twitter li { clear:both; } .widget_twitter li img { float:left; margin-right:.5em; } .widget_twitter li .clear { clear:both; }
Changelog
- 04/23/2008: 1.1.0
-
- Most major fix is the inclusion of json_decode.php for users that don’t have json_decode() which was added in PHP 5.2.0
- Fixed problem with displaying a useless li when profile images aren’t displayed on a single user widget
- Default title is now set to “Twitter: UserName”
- 04/17/2008: 1.0.0
-
- Released to wordpress.org repository
- 04/14/2008: 0.0.3
-
- Fixed some of the settings used with Snoopy
- Set a read timeout for fetching the files
- 04/14/2008: Version 0.0.2
-
- Changed some function names
- Moved form display to a separate function (_showForm)
- Now uses wp_parse_args to handle defaults
- Added comments to the code
- Added seconds to the _timeSince function so you can have something like “about 25 seconds ago”

le blog à Ollie » Liens du jour Says:
[...] Un widget Twitter pour WordPress. [...]
Raoul Says:
I’m looking for a WP twitter plugin at the moment, and ended here. Two questions:
1. Seeing how twitter is frequently down, does your plugin have some sort of caching device, in order not to slow down the loading of the page(s)?
2. I don’t want to use it as a widget. Any way to have good old tags instead?
Aaron D. Campbell Says:
Raoul Says:
Ok, thanks for your swift answers.
Julio Fernandez Says:
Hi Aaron, I’m a WP newbie. I added your Twitter widget and my host has php v 5.2.5. Two questions:
1. I see * Replace @username with a link to that twitter user
Is this right:?
sprintf(’http://twitter.com/statuses/%1$s_timeline/%2$s.%3$s%4$s’,$widgetOptions['feed'], $widgetOptions['oraclejulio'], $type, $count);
Are there any other places where I need to make changes?
2. I’m new to themes too. Your pluging was activated, but how do I add it to my right nav like you did?
Thanks @oraclejulio
Aaron D. Campbell Says:
Julio:
Those are things it does, not things you need to do. On twitter if you add a tweet, and put @aaroncampbell in it, it will link to my Twitter page. This widget does that too. It replaces @_____ with a link to that user on Twitter.
To add it to your sidebar, go to the admin section, then go to Design then Widgets. You will see it listed there, and can add it to an widgetized are of your theme.
ThePete Says:
When I try to use the widget in my WP 2.5 install (with php5) it blocks out the “save changes” button. However, I think when I first activated it it let me save changes, because now my sidebar doesn’t load properly when I try to pull up my site. So, I know it’s doing something. However, I’ve turned off the plugin so my sidebar will load properly. Not sure what is up, but wanted to let you know about it. Thanks!
Aaron D. Campbell Says:
ThePete: I sent you an E-Mail.
Joshua Kocurek Says:
Hi Aaron. Finally, a Twitter plugin that lets me show my friend’s feeds as well. I am excited to get this working. I have hit a snag though. I am running off of Wordpress 2.5 and when I install/configure the widget, I get this error on my sidebar where it is supposed to appear.
Fatal error: Call to undefined function json_decode() in /var/www/mist/wp-content/plugins/twitter-widget-pro/wp-twitter-widget.php on line 58
I checked that line, and even deleted the function, but it just led to more errors. Any insight you may have will be great. Thanks in advance!
Aaron D. Campbell Says:
Joshua: It seems that json_decode was not introduced until PHP 5.2.0. While I always recommend that you use PHP 5.2+ if possible, I have submitted a new version to the repository, which has a workaround using a modified version of ZendFramework’s Zend_Json_Decoder. PHP 5+ will still be required. It should be available from the wordpress.org repository in about 15 minutes, and is version 1.1.0. Let me know hoe it goes.
Joshua Kocurek Says:
Works flawlessly, Aaron! Thanks so much, keep up the good work!
Clesha Staten Says:
Hi Joshua.
I’m new to Twitter and trying to simplify as much as possible, so I’m excited that i found your plugin.
I installed it and got this message:
Plugin could not be activated because it triggered a fatal error.
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /xxx/wp-content/plugins/twitter-widget-pro/wp-twitter-widget.php on line 69
I am running the blog on MySQL 5.0
Thanks.
Clesha
Aaron D. Campbell Says:
Clesha: It looks like you have PHP4 and PHP 5+ is a system requirement for the plugin.
Joshua Decosta Says:
I would just like to know how to remove the rss button and make it look more clean on the site.
Teeth Maestro Says:
Hey - cool plug-in but I might have a bug for you to look into.
When you publish a Twitter feed in a sidebar the main title (which is an optional feed title setting) it adopts the URL of the latest Twitter that has commented on the profile and does not carry the URL of the main account
Example - in your blog - the left side bar has the Twitter feed of Kevin Rose. The RSS feed icon has the correct link [http://twitter.com/statuses/friends_timeline/kevinrose.rss] BUT the title ‘Kevin Rose’ should have [http://twitter.com/kevinrose] but as of my posting this comment it has the URL of MELKINK http://twitter.com/MelKirk which was incidentally the latest twitter on Kevin Rose’s account.
This bug is replicated on my blog as well. any way to work around this bug
Aaron D. Campbell Says:
Teeth Maestro:
You are absolutely right, I’ve added this bug to my list of things to do, and will try to get it fixed as soon as possible. Your plugins page should let you know when the new version is available.
Aaron D. Campbell Says:
I just uploaded version 1.1.2, which fixes the bug that Teeth Maestro found, and adds the option to hides the RSS icon as per request from Joshua Decosta. the new version should be available from the wordpress.org repository in about 15 minutes.
Please let me know if you find any other bugs!
La folie Twitter : 101 liens sur Twitter et + | Le Blog Kinoa Says:
[...] Wordpress Twitter Widget [...]
Raj Says:
Hi.. thanks a lot.. i am searching for this plugin for a long time.. But as i new to wordpress i dont know how to show profile picture in tweets.. i inserted the css that you provided in my default theme stylesheet.. but it doesnt works.. can you instruct me how to make it happen..
Aaron D. Campbell Says:
Raj: The CSS is really just to help you on your way to positioning the images properly, after they are enabled. To enable them, there is an option in the widget control. It’s a checkbox labeled “Show Profile Image(s)” and all you have to do is check it, and save your changes using the “Save Changes” button.
Raj Says:
Thank you so much Campbell.. I checked that option in my widget and it works fine.. Other doubt, How can I call the twitter function from a page without activating in sidebar..
Aaron D. Campbell Says:
Raj: That’s on the todo list, but it’s not really set up for that yet.
Firefly Says:
I get a similar error as one of your earlier commenters, however, your response is that the server isn’t running PHP5. I do host with a company that offers both 4 and 5, and I still get the error. Is there something I’m not doing correctly?
Firefly Says:
Nvm, I’m dumb. I found it.
DogSolitude » Blog Archive » WP Plugin: Wordpress Twitter Widget Says:
[...] Plugin: Wordpress Twitter Widget. I don’t use the twitter. Buy maybe I will. Althought I can post right here with [...]
Andy Simpson Says:
Hey, I started using your plugin when Twitter.com was down, so it didn’t behave the best, so I hacked it a bit to add in a “Twitter could not be contacted” error message.
I changed a section in _parsefeed() to:
// Failed to fetch url;//return array();
// Error message bubble-up
return array("urlerror" => "Could not contact Twitter");
and in display() :
echo $before_title . $options[$number]['title'] . $after_title;?>
<?php
//Display error message if there was a timeout:
if(array_key_exists(”urlerror”, $tweets))
{
echo $tweets["urlerror"];
// Zero-out the array so the logic below works.
$tweets = array();
}
if ( $options[$number]['feed'] == ‘user’ && !empty($tweets) && $options[$number]['avatar']) {
Some of your code left in above and below for context. This gives a more user-friendly message, rather than just showing no Tweets! Hope you’ll consider using this in the next version.
Aaron D. Campbell Says:
Thanks Andy. I’ll probably go about it slightly differently, but I’ll make sure to have an error in the next version. Look for it tomorrow!
Aaron D. Campbell Says:
Some error reporting has been added. It will say ‘Could not connect to Twitter’ if it couldn’t connect, and ‘No Tweets Available’ if there weren’t any tweets.
Aengus MacKenzie Says:
Hello I love this plugin but I have a problem with the time/date stamp. Everything shows on my blog as posted on December 31st, 6:59:59 1969
When I go to twitter manually the time is correct. My posts on my blog are correct. I can’t figure out where that time is being pulled from.
Any ideas?
Aaron D. Campbell Says:
Aengus: I haven’t seen that happen. Could you send me a link to the site?
Aengus MacKenzie Says:
Thanks for getting a look. I don’t know its your plugin’s behavior at all, I cant figure out where this date is coming from.
http://www.flaxpond.net
Aaron D. Campbell Says:
Aengus: it looks like strtotime() can’t convert the time it’s getting from Twitter. However, I can add your feed to my test site fine. Your host says you’re running PHP 5.0.4, do you have any idea what your locale is set to? Maybe it doesn’t understand the date from twitter because it’s in English (”May” etc) and your PHP is set to something else? If you could find out, I’d appreciate it.
Aengus MacKenzie Says:
I got a response from my hosting company. Here it is.
———————————————-
UTF-8 multi language for better support of all possible characters
Разбираемся в виджетами → Блог Антона Соткова Says:
[...] Twitter Widget Pro — тот, что я использую (не без небольших поправок в коде). Принцип работы сож с предыдущим, однако этот имеет чуть больше настроек, позволяя, например, отображать не только ваши твиты, но и тех, на кого вы подписаны. Существует защита для случаев недоступности сайта (будет выводиться соответствующее сообщение, а также он распознает «@-ответы», ставя ссылку на адресата. Мои правки заключаются в том, что я локализовал вывод времени, убрал сведения о клиенте (их можно вернуть) и добавил пару дивов для того, чтобы настроить внешний вид под себя. Если вам он вдруг понадобится (моя версия), то обращайтесь. [...]
Zac Says:
This widget needs three things to make it perfect:
1) Automatic reconnect attempts of the twitter feed after a failed connection to update the widget. (If this already happens, perhaps a means of adjusting how often it checks from the config page.)
2) Personalized (customizable) connection error message that can be setup on the widget config page when the plugin can’t retrieve the twitter feed.
3) Functional fail-over to a local cache of the most recent successful tweet. (If already present, it is not working.)
Otherwise this plugin/widget is GREAT! Thanks for all your work! Your efforts are greatly appreciated.
What Wordpress Plugin’s Do I Use? | Creeva's World 2.0 Says:
[...] Twitter Widget Pro [...]
HighTechDad Says:
I just installed your plugin (have been searching for a better twitter client due to all of the downtime that twitter has been having). I did an RSS feed of my own which works ok.
Now trying your plugin, I get the “Could not connect to TWitterr” even though twitter is up.
Any thoughts on this? Looks like a nice plugin though.
Drew Says:
Hmm… This isn’t saving when I hit “save changes”; all of the parameters go back to being empty.
Drew Says:
Never mind, I see it requires WP 2.5…
List of Twitter Plugins for WordPress | Earn Blogger Says:
[...] Twitter Widget Pro : A widget that properly handles twitter feeds, including @username and link parsing. Feeds can be for a single user, or can include all their friends’ tweets as well (like their Twitter home page does). It supports displaying profiles images, and even lets you control whether to display the time and date of a tweet or how log ago it happened. [...]
Dulce Says:
Hi… the plugin couldn’t be activated because it triggered a fatal error:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /home/dlc/public_html/wp-content/plugins/twitter-widget-pro/wp-twitter-widget.php on line 82
I’m using PHP 5.2 by the way. Please help. Thanks.
Aaron D. Campbell Says:
Dulce: That error should only occur if you are trying to run it using PHP 4.x rather than PHP 5.x
Make sure that PHP 5 is actually parsing your PHP documents. You can echo out the PHP_VERSION constant, or create a php file called “phpinfo.php” and put in it:
< ?php phpinfo(); ?>Then open that file from a web browser to see all sorts of stats about your PHP installation. If you find you are running PHP 5, contact me and send me a link to the phpinfo.php file.
Remko Says:
Is it possible to get this plugin working with the sidebar manager of K2? I’m still trying to figure it out, put it seems that I have to change the Twitter Widget code.
Steve Says:
Presume you’re aware the friends_timeline has been hit? See: http://www.slobokan.com/archives/2008/06/01/adding-fuel-to-the-fire/
Great tool btw!
peter Says:
@HighTechDad: For the “Could not connect to TWitterr” problem - the plugin does not work as long as you have “Protect my updates” enabled….
Zasta Says:
Great Widjet!
It automatically blended with my custom theme. Thanks a bunch!
Paul Says:
I tried to install but when I activated it I got this error message:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /var/www/vhosts/faith-journey.com/httpdocs/wp-content/plugins/twitter-widget-pro/wp-twitter-widget.php on line 82
Any ideas?
Aaron D. Campbell Says:
Paul: That error occurs when you are trying to run this plugin using PHP 4.x rather than PHP 5.x (which is requires). Please versify that you have PHP 5
Ryan Says:
The plugin is working fine for me when I have it set to “Just User,” but when I switch to “With Friends,” I get the “Could not connect to Twitter” function. Any idea what’s going on?
Aaron D. Campbell Says:
Ryan: Unfortunately, yes I do. Twitter has removed that functionality. a new version of the plugin is in the works that will remove this option. Unfortunately, with my schedule it will probably be a little while.
Steve Says:
I guess adding user/pw authentication is out of the question?
Aaron D. Campbell Says:
Steve: Actually, it’s on the TODO list, but was outside the scope of what I could get done in the timeframe I had to work on it. Hopefully it will make it in the next update.
Dave Zatz Says:
Hi Aaron, Looks like a great update and I have no problem sharing the usage data to assist you.
Was wondering if you could give me a pointer though. I want to customize the CSS so the text of my tweets are white and so that the hypertext-linked content is italicized. I can do that on my own, if you could give me the classes I might need.
Thanks again!
Aaron D. Campbell Says:
Dave Zatz: Thanks! Here is the info you need:
So, you can use something like:
.widget_twitter .entry-content {color:#FFF;
}
.widget_twitter .entry-content a{
font-style:italic;
}
If you find that these css styles are being overwritten by more specific ones, you can always add additional steps in there like:
.widget_twitter ul li span.entry-content {color:#FFF;
}
.widget_twitter ul li span.entry-content a{
font-style:italic;
}
Dave Zatz Says:
Awesome, I’m making progress now. If you’re taking requests, I’d like the option to unlink the title from my Twitter URL and I’d the option to not display the source of my Tweet. I have limited space and I don’t know that it’s useful info. Thanks again!
Polcampaign Says:
I love the idea of using Twitter on a regular basis on my wp political blogs.
A. I’m having a hard time, since I don’t know diddly about backend work, getting your widget to display after being uploaded to the plugin file. I can use help there.
B. Once you help me get past that simple, I’m sure it’s simple, roadblock is it possible to configure to have the Tweet as a main page, rather than sidebar, post?
You may contact me directly if you wish. I may have some work for you.
Thanks in advance for the time and effort.
Josh Lee Says:
Is there a way to just include this plugin in the template page instead of using a widget? Love it’s functionality but need to be able to just plug it in without using it as a widget.
Any help on that?
cheers
josh
Aaron D. Campbell Says:
Josh Lee: It’s on the TODO list, but with the way work has been, it might be a little while.
Josh Lee Says:
ok np. Will keep checking.
Quick test | Scott's Spiel Says:
[...] it did. The plugins that finally got my setup here are Twitter Updater and Twitter Widget Pro. Took a while to find plugins that were 2.5.1 compatible but these do the [...]
Alex Dunne Says:
Hi-
I’m getting “Could not connect to Twitter” on my Twitter feed, even though my feed is not protected. I see on the top of your own web page (http://xavisys.com/wordpress-twitter-widget/) that your Twitter feed is also displaying the same message.
Do you know if Twitter is blocking access to their site using whatever update method your plugin uses?
Thx!
Alex Dunne Says:
I retract my last note - it now seems to be working on my site and your site. I’ll chalk that up to typical Twitter flakiness.
Thx for a great plugin!
FreakLikeMe » Blog Archive » Wie aus Wordpress ein Twitter, Soup.io, Blog Mashup wird. Says:
[...] Twitter auch einen gebührenden Platz auf dem Blog bekommt, wird fix das Twitter Widget Pro installiert. Schon gibts die Tweets schön im Sidebar, mit RSS [...]
Paul Says:
Hi, I get the following error message when I activate the plugin:
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /var/www/vhosts/faith-journey.com/httpdocs/wp-content/plugins/twitter-widget-pro 3/wp-twitter-widget.php on line 93
Thanks for your help
Freiheitsfreund » Archiv » Twitterei die 2. Says:
[...] mit dem Blog Freiheitsfreund verwoben. Beiderseitig. Dank der Wordpress-Plugins Twitter-Updater und Twitter Widget Pro. Scheint zu funktionieren soweit. Ach wie klasse es doch ist, sein Wordpress selbst zu [...]
IES Says:
I use PHP Version 5.1.4-Debian-0.1~sarge1
and could intall the extension without a problem. But the widget either tells me Twitter is down (when it is not) or shows the following error where the widget should be:
Fatal error: Class ‘Zend_Json_Exception’ not found in /hp/af/ac/jw/www/iestankov/blog/wp-content/plugins/twitter-widget-pro/json_decode.php on line 321
The functionality of the widget seems to be perfect, so I really would appreciate some help in getting it to work!
Aaron D. Campbell Says:
IES: I fixed the Fatal error, and added an option to increase the timeout when trying to reach Twitter. The default is 2 seconds, but if you have a slower connection to Twitter, or if Twitter is running slowly, that might not be enough. I just uploaded version 1.2.2, so it should be available in about 15 minutes.
Dan Says:
Hello,
Is there a way to use this widget without using the native Wordpress Widget Interface ? I want to to call it from my sidebar.php file. I hate using widgets because very little customization options are available.
Aaron D. Campbell Says:
Dan: Unfortunately there is not. I have plans to add that in the future, but haven’t had time to work on any of my plugins recently because I’ve been too busy with work.
Cliff Says:
Heya!
I know this is a rather daft question, but is it possible to not link the title to my twitter page? Also I would like to custimize the css of the title, is that possible?
Cheers, Cliff.
Aaron D. Campbell Says:
Cliff: You can’t currently set where the title links. However, you can easily style everything in it just by adding CSS styles to your main style sheet. Here is the info you need:
So you can use something like:
.widgettitle {/* Your styles here */
}
Cliff Says:
Perfect, thanks a lot!!
Cheers, Cliff.
Freiheitsfreund » Archiv » Twitter und Blog Says:
[...] berichtet. Allerdings sind sowohl die dort von mir genannten Twitter updater als auch Twitter widget pro wieder [...]
justelise Says:
Is it possible to have this plugin not display where each tweet is coming from? I don’t want it to display “from web” or “from Facebook” because it just looks sloppy. It’s inconsistent as to where the location is going to show up. Sometimes it’s before the text in the tweet (”for web”), and sometimes its after it on a new line (”from Facebook”). I just want to clean up the appearance.
Aaron D. Campbell Says:
justelise: Not as of now. You could hide the time and “from” using CSS:
.widget_twitter .entry-meta {display:none;
}
However, the from _____ line always appears in the same place. The only reason it should go to another line is if the phrase is too long.
21 verktyg för att göra livet enklare på Twitter | Webmastern.se Says:
[...] Wordpress Twitter Widget En widget för Wordpress som visar dina och dina kontakters tweets på din [...]
Updated WordPress Twitter Widget Says:
[...] recently installed the Twitter Widget Pro (originally built at Xavysis) on the site, and realized it didn’t cache the twitter feed for more than a few seconds. [...]
Philix Says:
This is a great plug in
Armand Minotti Says:
So I’m trying the plugin on a new wordpress 2.5 blog with php 2.5.6, but it always says that twitter is down, even thought it isn’t, and the plugin seems to be connecting fine on your own page. Any ideas?
Armand Minotti Says:
I meant to say wp 2.6. Whoops.
Mindless Rambles / Plugins I use Says:
[...] Twitter Widget Pro - A widget that properly handles twitter feeds, including @username and link parsing, and can even display profile images for the users. Requires PHP5. [...]
Twitter Wordpress Plugins : Wordpress Plugins Says:
[...] WordPress blog. You can pick and choose when Plurks are sent and what text is passed along with it. Twitter Widget Pro Displays your twitter feeds on your blog, including @username and link parsing, feeds that include [...]