There are a lot of plugins for WordPress that deal with Twitter. It can be hard to find the right one when you have a specific feature in mind. Although there are some really useful ones, sometimes a plugin is not always the answer. If you want to add your latest tweets to your blog but you don’t have the resources for another plugin, or you just like doing things by hand, here is some code you can use to add your latest tweets from Twitter to your blog without a plugin.

Everything we need can actually be accomplished in three lines of code.

The first bit of javascript we need to accomplish this is supplied to us by Twitter.

<script type="text/javascript" src="https://twitter.com/javascripts/blogger.js"></script>
<script type="text/javascript" src="https://twitter.com/statuses/user_timeline/USERNAME.json?callback=twitterCallback2&count=1"></script>

You’ll want to change USERNAME to your Twitter username. You can also change count=1 to whatever number of Tweets you want to show up. You are best to put this script somwhere at the bottom of your template. That way if there is any load issues at Twitter your blog page will still load first.

Now all you need is a line of HTML code to display the Tweets.

<div id="twitter_div"><ul id="twitter_update_list"><li>&nbsp;</li></ul></div>

It is up to you where you want your Tweets to appear. If your blog is widget-ready you can simply paste this HTML code into a text widget and drag it to the desired location. You can also manually edit sidebar.php or even put it in the header or footer of your blog.

From here you are free to add a new selector to your stylesheet to style the updates. Make a CSS selector with the ID ‘twitter_div’ and style it as you see fit.