Display your latest twitter entry on your wordpress

November 4, 2008 · Print This Article

Many bloggers uses twitter, which is a very great way to socialize with other bloggers and promote your posts.

Displaying your latest twitter entry on your blog is a good idea to help your readers staying tuned with you.

To display your latest twitter entry, just paste the code below anywhere on your blog.




// 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 = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";

function parse_feed($feed) {
$stepOne = explode("", $feed);
$stepTwo = explode("", $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);

That’s all! Your latest twitter entry is now displayed on your blog.

Your choice for site templates and wordpress themes


One Response to “Display your latest twitter entry on your wordpress”

  1. simarjeet singh on April 26th, 2011 1:45 pm


    thanks for this script

    working very well,

    but i have a question?

    is there any limit to access data my mean to hit a URL .

    is there any limit to hit a URL on twitter in one day or month.

    hope u can understand what i am asking you.

Got something to say?

You must be logged in to post a comment.