Display last tweets on your wordpress blog
March 14, 2010 by stefan · Leave a Comment
It is very useful to show your Twitter account on your wordpress blog by displaying your last tweets. To do this, we need to accomplish 2 steps.
First step
Open in editor function.php file and add at the end the code below:
<?php
function displayLatestTweet($twitterID){
include_once(ABSPATH.WPINC.'/rss.php');
$latest_tweet = fetch_rss("http://search.twitter.com/search.atom?q=from:" . $twitterID . "&rpp=1");
echo $latest_tweet->items[0]['atom_content'];
}
?>
Second step
Open in editor the sidebar.php file and add next code:
<h2>Latest Tweet</h2>
<p><?php displayLatestTweet('twitter_account'); ?></p>
Do not forget to change the twitter_account to your Twitter account name.
Related posts: