Archiving Twitter With WordPress

Yesterday I had a spare cou­ple hours and decided to fol­low Doug Bowman’s exam­ple and set up a self-hosted archive of my Twitter stream with WordPress. You can see the fin­ished prod­uct of that here.

There was some inter­est expressed on Twitter of oth­ers want­ing to do some­thing sim­i­lar so I thought I’d help out by mak­ing what I did avail­able for down­load. You can grab a copy of the theme and required plu­g­ins which will pro­vide pretty close to a turn key solu­tion for get­ting this running.

I highly sug­gest fol­low­ing Bowman’s tuto­r­ial for down­load­ing and import­ing the ini­tial archive of pre­vi­ous tweets. Once you have that done and the plu­g­ins and theme are installed there’s a cou­ple things you’ll want to do:

  • Replace the profile_image.jpg file in the theme folder with your own pro­file image.
  • Head to your pro­file page within your WordPress instal­la­tion. You’ll see two new fields, one for the url of your Twitter pro­file and the other for your Twitter user­name. These power the text in the header so just fill them both out and the header text will be linked to your profile.
  • The tagline below the user­name in the header is pulled from your blog’s tagline so fill that out in General tab under­neath Settings.
  • Setup Twitter Tools to cre­ate a new blog post every time you tweet. You can find more infor­ma­tion about doing that at the WordPress plu­gin direc­tory.
  • Run two queries using the Search Regex plu­gin (for more info on these queries read the orig­i­nal source). This will link up all the @usernames and #hash­tags from your tweets.
    • For @usernames enter /(^|s)@(w+)/ into the Search Pattern field and then enter 1@<a href="http://twitter.com/2">2</a> into the Replace pat­tern field. Check the Regex box.
    • For #hash­tags enter /(^|s)#(w+)/ into the Search pat­tern field and then enter 1#<a href="http://search.twitter.com/search?q=%232">2</a> into the Replace pat­tern field. Check the Regex box.
    • In both cases I sug­gest run­ning a Replace before run­ning Replace & Save. This will allow you to look every­thing over before mak­ing changes that will affect your database.

That’s it. After doing those steps you should have a search­able, self-hosted archive of every­thing you’ve posted on Twitter. If you run into ques­tions or prob­lems feel free to fire away in the comments.

Update 3/23: Emily Ingram pointed me to a plu­gin that will achieve the same auto-linking of @replies and #hash­tags that the regex calls do. It’s a super sim­ple solu­tion and can be down­loaded from the WordPress direc­tory. Sounds like it works quite well.

3 thoughts on “Archiving Twitter With WordPress

  1. WordPress is actu­ally adding those curly quotes, not your font, via a nifty func­tion call wptex­tur­ize(). It won’t add curly quotes inside <code> tags, though.

  2. I really wish I had in some way backed up my twit­ter account before it got hacked. It would have been really smart to backup the data on my server, I’ll try it in the future.

    Also, three Andrew’s in a row FTW.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>