How To Display Twitter Updates Without Plugin

How To Display Twitter Updates Without Plugin

Recently I was working on my friend’s DJ site.  He wanted me to install Twitter updates on the homepage.  In order to do this I had to add a script to the home page.  Luckily, via WP Recipes, I found the script I was looking for!  Thanks to the site you can copy the below script and paste it anywhere on your WP blog.  Make sure you replace your “TwitterUsername” with your Twitter name.


// 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 = “<h2>My Last Tweet</h2>”;

// Suffix – some text you want display after your latest tweet. (Same rules as the prefix.)
$suffix = “”;

$feed = “” . $username . “&rpp=1”;
function parse_feed($feed) {
$stepOne = explode(“<content type=\”html\”>”, $feed);
$stepTwo = explode(“</content>”, $stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace(“&lt;”, “<“, $tweet);
$tweet = str_replace(“&gt;”, “>”, $tweet);
return $tweet;

$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);

, , , ,