oAuth Twitter Feed for Developers is a brilliant plugin to show your latest tweets on your WordPress website. Once installed and setup (you’ll need your OAuth Consumer Key, OAuth Consumer Secret, OAuth Access Token and OAuth Access Secret which can be found on your Twitter dashboard) you need to add a code snippet to your template.

The standard code is, where you’d need to replace the username, shows the last tweet with no links or formatting.

<?php
$tweets = getTweets(1, 'ElectricStudio', array('exclude_replies' => true, 'include_rts' => false));
foreach($tweets as $tweet){
echo $tweet['text'];
}
?>

However, if you want to format them to be wrapped in a unordered list, UL, the code example below will pull in the last 3 tweets from the user ElectricStudio, and wrap it in UL/LI tags and include any embedded links for each tweet.

<ul>
< ?php
$tweets = getTweets(3, 'ElectricStudio', array('exclude_replies' => true, 'include_rts' => false, 'include_entities' => true));
foreach($tweets as $tweet){
$tweet_text = $tweet["text"];
$tweet_text = preg_replace('/http:\/\/([a-z0-9_\.\-\+\&\!\#\~\/\,]+)/i', '<a href="http://$1" target="_blank">http://$1</a>', $tweet_text); //replace links
$tweet_text = preg_replace('/@([a-z0-9_]+)/i', '<a href="http://twitter.com/$1" target="_blank">@$1</a>', $tweet_text); //replace users
echo '<li>'.$tweet_text.'</li>';
}
?>
</ul>

Have you got any better suggestions on how to implement your latest tweets? Feel free to share.