To display your latest tweet on your site just add the following function in your functions.php file.

function stf_get_latest_tweet($username){

	$tweet = get_option("stf_lasttweet");
	
	$url = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
	
	if ($tweet['lastcheck'] < ( mktime() - 60 ) ) {

		$feed = file_get_contents( $url );
		$stepOne = explode("<content type="html">", $feed);
		$stepTwo = explode("</content>", $stepOne[1]);
		$output = $stepTwo[0];

		$output = htmlspecialchars_decode ( $output , ENT_QUOTES ); // Decode all HTML entities
		
		$tweet['lastcheck'] = mktime();
		$tweet['data'] = $output;
		
		update_option( 'stf_lasttweet', $tweet );
		
	} else {
	  $output = $tweet['data'];
	}

	return $output;
}

This function returns your latest tweet as html. To display it on your site use this call anywhere you like in your theme:

<?php echo stf_get_latest_tweet("shailancom"); ?>

Enjoy!

Deal Notice: We are using A2 hosting for all of our websites, and we are really happy with their service. So we wanted to share you this discount link for you to try it out. If you get a hosting using this link, you will also help us build better content for you: SSD Hosting - 300% Faster Than Standard Hard Drives