Proud of your tweets? Maybe you run a business blog and would like to integrate your Twitter feed? For WordPress users, adding your most recent tweet to your WordPress blog is actually very easy. Simply add a little code snippet in your blog’s sidebar where you want to display your most recent tweet, then add your Twitter username!
Here is the code you’ll need to easily add the most recent Twitter entry:
<?php
// Your twitter username.
$username = "TwitterUsername";
// Prefix - some text you want displayed before your latest tweet.
// (HTML is OK, but be sure to escape quotes with backslashes: for example href=\"link.html\")
$prefix = "";
// Suffix - some text you want display after your latest tweet. (Same rules as the prefix.)
$suffix = "";
$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
function parse_feed($feed) {
$stepOne = explode("<content type=\"html\">", $feed);
$stepTwo = explode("</content>", $stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace(”<”, “<”, $tweet);
$tweet = str_replace(”>”, “>”, $tweet);
return $tweet;
}
$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
?>
Simply add your Twitter username where it says “TwitterUsername” in the code above!






Thank you. I’m going to use it on my new site which I am developing in WordPress. I would like to show my twitter avatar photo too, is that possible?