Make your Twitter badge validate

If there is anything I hate more than unreturned emails it’s doodads that make my pages fail validation.3rd on my list are people who breathe audibly and 4th are people who eat audibly. Once I fell asleep while 2 of my pals were eating pizza and their chomping and slurping noises made me sick to my stomach…while I was sleeping!

Less is more

I am trying to rely less on plugins. After the recent upgrade and ensuing bruhaha over beloved plugins that didn’t work with 2.5, I am loathe to add new ones to my “have to have” list if I can help it. Many times a plugin is a labor of love and the author will work hard on getting it to work with the latest version of WordPress.

But the plugins that kinda sorta worked but that you loved probably won’t be.Then there are the plugins that haven’t worked since version 2.2.1. There are folks stuck on an old version of WordPress because they can’t bear to give up one little plugin (which was probably remade better by someone else,anyway).

It’s just a plugin

These folks are missing the point,I think. Plugins are meant to enhance your blog or site–not be the focus of it. If you are not upgrading because of a plugin or two of course that is your choice.But if you look around you’ll find a replacement. I researched a list of plugins I need for a client’s site and and found their WP 2.5 compatible doppelgangers,no sweat. If only that client would return my emails and give me the go ahead I can upgrade his site from 2.1., I’d be happier.

Old school

So I chose to use the html & javascript badge instead from Twitter. Only thing is, it has an “unfinished” <ul></ul> in the block of code and no ampersand in the javascript url. That amounts to 4 errors but it’s easy enough to fix.
I just mixed the block of code up until it validated and worked (kind of important,no?).
And anyway if you are using this in a text widget you don’t need the <h2 class=”twitter-title”>
so snip that right out and use the title space in the text widget instead.
*edited because the ampersand got parsed,duh*

The Twitter Badge

<div id=”twitter_div”>
<h2 class=”twitter-title”> Twitter Updates </h2>
<ul id=”twitter_update_list” </ul> </div>
<script type=”text/javascript” src=”http://twitter.com/javascripts/blogger.js”></script>
<script type=”text/javascript” src=”http://twitter.com/statuses/user_timeline/ »»
MY_TWITTER.json?callback=twitterCallback2&count=5″></script></div>

Url was too long, »» shows the line break.

This is one culprit:
<ul id=”twitter_update_list” </ul> </div>
I added an empty set of li tags: <li></li> and put them inside the ul tags.
This is the other culprit. I added an ampersand:
MY_TWITTER.json?callback=twitterCallback2&count=5

A Twitter Badge that validates

<div id=”twitter_div”>
<ul id=”twitter_update_list”> <li></li> </ul> </div>
<script type=”text/javascript” src=”http://twitter.com/javascripts/blogger.js”></script>
<script type=”text/javascript” src=”http://twitter.com/statuses/user_timeline/ »»
MY_TWITTER.json?callback=twitterCallback2&count=5″></script></div>

MY_TWITTER should be replaced with your Twitter username.

I don’t use Twitter enough to put a badge in my sidebar, I edited the block to be valid for my friend’s site.