Wordpress Latest Twitter Sidebar Widget
I made a Wordpress widget to display latest Twitter updates for any Twitter user in a Wordpress website’s sidebar. A widget is activated just like a plugin on any “widget ready” theme and can be positioned within the sidebar using the drag and drop Widget page in the Administration Dashboard.
There are a handful of “latest tweet” plugins and widgets available, but most of them require your web server to be running PHP5. This widget uses the DOM XML object in PHP4.
I based this project on some code written by Ryan Barr. I added some sauce and already have a nice idea of where the next version will progress.
UPDATE: 0.081204
This widget can now display more than one Twitter update. I have abandoned Ryan’s code, but I still credit his example for introducing me to the Twitter API. This version uses the DOM XML extension, and is still PHP4 friendly.
UPDATE: 0.090401
No code edits required. I have built an options form to allow all configuration via wp-admin/widgets.php. I have created a WP option called ‘widget-latest-twitter’ to store the customizable values.
UPDATE: 0.100210
This will be the last version of this plugin that runs uses PHP4’s DOMXML object. All future versions published to this plugin’s page on the Wordpress Plugin Directory will be PHP5 only. Click here to download the last PHP4 compatible build from my server, version 0.100210 of this plugin.
Installation Instructions
- Download latest-twitter-sidebar-widget.zip
- Decompress the file contents
- Upload the latest-twitter-sidebar-widget folder to a Wordpress plugins directory
- Activate the plugin from the Administration Dashboard
- Open the Widgets page (wp-admin/widgets.php) under the Appearance section
- Drag the Latest Twitter widget to the active sidebar, edit and Save changes.
You may also visit Latest Twitter Sidebar Widget’s home away from home in the official WP Plugins Directory, where neat download stats reveal hundreds of people have downloaded my code.
Comments(23)

Ahhh..I’ve been looking for something like this. What if you wanted to display your last 2 tweets and not have the icon so large?
I suppose such a circumstance would mean you are waiting for updates :)
I have yet to submit this to the WP Codex, and I am already planning the creation of a readme file. Stay tuned for additional changes.
hi! thanks for the widget!
Can you help me – what code should I write to my footer.php to run your widget?
I am making my own theme, very complicated.Widget code in sidebar.php is disabled by me because I need to load widget code at very specific places. So, at the place where I need twitter posts to appear I am trying to call init_latest_twitter(), but all I get in result is the pisture of twitter and the “Latest on twitter” header :(
So, maybe I am calling the wrong func?
Vadim,
Thanks for your interest in my widget plugin. You have actually caught me mid-update. I have made some changes to this plugin this week, and I am waiting for wordpress.org to list the new version of this code, version 0.090305, to be posted on the WP Codex download page.
I emailed you a .zip file containing the latest code. Give it a shot and let me know if the results are the same. I am not familiar with footer-ready widgets, but I am willing to make more updates to my code if it helps you out.
The local copy of this plugin is always the latest version and can be downloaded through this link.
when I install it it shows this error :
Fatal error: Call to undefined function domxml_open_file() in /usr/home/mano-ftp/wp-content/plugins/latest-twitter-sidebar-widget/latest_twitter_widget.php on line 105
manofstyle,
This means DOM XML is not installed on the server you are using. Write a phpinfo script like this:
<?phpphpinfo( );
?>
What version of PHP does it say your server is running? Does it mention DOM XML? If not, you may need to install this component on the server so this PHP object can be used. http://us2.php.net/domxml
[...] Creates a sidebar widget that displays your latest Twitter update for any given user. Visit Twitter Sidebar Widget [...]
I also get…
Fatal error: Call to undefined function domxml_open_file() in /usr/home/mano-ftp/wp-content/plugins/latest-twitter-sidebar-widget/latest_twitter_widget.php on line 105
I’ve checked my php settings and I have domxml..
DOM/XML enabled
DOM/XML API Version 20031129
libxml Version 2.7.3
HTML Support enabled
XPath Support enabled
XPointer Support enabled
Schema Support enabled
RelaxNG Support enabled
Any other ideas for getting this to work?
Ok. This plugin needs an options form. I will try abandon DOMXML during this rewrite so the code runs on more servers. Stay tuned, there is no time like the present.
My server is running both PHP4 & 5 with 5 as default. I could force it to load the script under PHP4 but would prefer not to. Another option for users could be to use Alexandre Alapetite’s domxml-php4-to-php5.php wrapper http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/index.en.html
Corey that link may be of help in your re-write.
Cheers
Hi – thanks for all you do. I’m a relatively new Wordpress user and am having difficulty installing the twitter sidebar widget. It says, “No response from Twitter.” Can you help point me in right direction? I don’t use CSS/any upgrades that get into the underpinnings of the code – is this the problem? I’d be willing to upgrade. Thanks.
@Matt I should be able to write a PHP5 version this week. I’ll send you an email when it’s ready.
@Susan Thanks for checking out my widget. Are you using Wordpress.com or Wordpress.org?
hey,
awesome widget. is there a way to edit the css? there is too much negative space between tweets for my liking…
thanks again
Sure, look for the variables $beforeUpdate and $afterUpdate in the code. As of version 0.090401, each update is wrapped in a <p> tag. It is possible that your theme’s stylesheet is defining padding or margins on this element.
I have PHP4 running on my server and I’m getting this error code
`htmlspecialchars_decode() expects parameter 1 to be string, NULL given in /web/sites/pamulex/utahacres.com/land/wp-includes/compat.php on line 105`
I just uploaded this plugin and also get a reading of:
Fatal error: Call to undefined function domxml_open_file() in /usr/home/mano-ftp/wp-content/plugins/latest-twitter-sidebar-widget/latest_twitter_widget.php on line 105
Did you ever find a solution to this issue? I’m not very code savvy, so the simpler, the better. Thanks!
Billie:
That error is not occuring in my file. Try deleting the htmlspecialchars_decode function from my plugin.
Samantha:
That means your version of PHP doesn’t support the code my plugin uses. If you are not very technical, you probably have to wait for me to come out with a PHP5 version, or choose another plugin.
For those facing “Fatal Error” messages, we think your problems can be solved if you contact your host and ask them about the safe mode. Some “paranoic” hosts use to do that…
Cheers!
[...] Creates a sidebar widget that displays your latest Twitter update for any given user. Visit Twitter Sidebar Widget [...]
This looks very promissing, however, I just uploaded your widget to my WordPress blog and received the error message:
Fatal error: Call to undefined function domxml_open_file() in /home/content/f/i/d/fiducia/html/govdave/wp-content/plugins/latest-twitter-sidebar-widget/latest_twitter_widget.php on line 83
I use GoDaddy hosting running on Linux with PHP5 – Can you help?
Drew:
That means your version of PHP doesn’t support the code my plugin uses. If you are not very technical, you probably have to wait for me to come out with a PHP5 version, or choose another plugin.
Thanks for the wonderful plugin. I had the same error too as I am running on an Apache server with PHP 5.0 Looking forward to your new plugin.
Thanks.
[...] Download: Latest Twitter Sidebar Widget Plugin Homepage: Latest Twitter Sidebar Widget [...]