Display Latest Tweets on Your WordPress

December 22nd, 2009 By WP Tricks Posted in Tips

Twitter is phenomenal, almost every internet user have this account, they share everything in Twitter. There are so many method how to display Latest Twitter on your WordPress, we can use display as simple rss, using Twitter Widget or using much advantage method to display twitter. On this Tutorial, I will show you how to display your latest twits with more sophisticated method.

Open your sidebar.php theme (if you want display this tweet on your sidebar) and write this code below

<div class="latest-twit">
<?php
$feedURL = "http://twitter.com/statuses/user_timeline/68559295.rss" // change to your feed URL
$doc = new DOMDocument();
$doc->load($feedURL);
$arrFeeds = array();
foreach ($doc->getElementsByTagName('item') as $node) {
    $itemRSS = array (
        'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
        );
    array_push($arrFeeds, $itemRSS);
}
$limit = 5;
for($x=0;$x<$limit;$x++) {
    $title = str_replace('bavotasan: ', '', $arrFeeds[$x]['title']);
    $str = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $title);
    $pattern = '/[#|@][^\s]*/';
    preg_match_all($pattern, $str, $matches);

    foreach($matches[0] as $keyword) {
        $keyword = str_replace(")","",$keyword);
        $link = str_replace("#","%23",$keyword);
        $link = str_replace("@","",$keyword);
        if(strstr($keyword,"@")) {
            $search = "<a href=\"http://twitter.com/$link\">$keyword</a>";
        } else {
            $link = urlencode($link);
            $search = "<a href=\"http://twitter.com/#search?q=$link\" class=\"grey\">$keyword</a>";
        }
        $str = str_replace($keyword, $search, $str);
    }
    echo '<li>'.$str.'</li>';
}
?>
</div>

That’s all and you can made some custom on this design by play around with your css skills. Thanks for Batovasan for share this code. If you have better idea how to display latest tweets in WordPress please let’s me know

Display Latest Tweets on Your WordPress On The NET

Display Latest Tweets on Your WordPress # WordPress Tricks & Tips

Twitter is phenomenal, almost every internet user have this account, they share everything in Twitter. There are so many method how to display Latest Twitter on read more

Source: http://wptricks.net/display-latest-tweets-on-your-wordpress/

How to display your latest tweets in your WordPress blog without a ...

Yes, I know. This article has been written a thousand times before. But this solution is different. It doesn’t require a plugin, and it’s very easy to implement. read more

Source: http://dinolatoga.com/2010/07/31/how-to-display-your-latest-tweets-in-your-wordpress-blog-without-a-plugin/

Display latest tweets on your Wordpress blog or website without a ...

Here's a simple solution for displaying your latest tweets on your wordpress blog or website without a plugin or hard coded php. read more

Source: http://www.skatdesign.com/blog/how-to/display-latest-tweets-wordpress-blog-website-without-plugin.htm

WordPress › Latest tweets « WordPress Plugins

There is a wide choice of widgets which you can put in your WordPress sidebar, but I could not find one that would display a defined number of my latest tweets. read more

Source: http://wordpress.org/extend/plugins/latest-tweets/

How to Display Your Twitter Posts on Your WordPress Blog ...

... plugin and some basic CSS and XHTML to display your Twitter tweets on your WordPress-powered blog ... should cause the plugin to make a new request for your latest tweet and display it ... read more

Source: http://perishablepress.com/press/2008/03/22/how-to-display-your-twitter-posts-on-your-wordpress-blog/


Amazing Touch


6 Comments

  1. i need latest entertainment update on my blog mostly naija update.

  2. very nice blog :)

  3. aljuk

    It’s not working for me. Copied and pasted exactly, simply changed the feed data to my feed.

    Parse error: syntax error, unexpected T_VARIABLE

    • claire

      Hi,
      You’ve probably figured this out already by now but just ad a semi colon after your feed like

      $feedURL = “http://twitter.com/statuses/user_timeline/68559295.rss”;

      It’s just missing from the example.

  4. to those who made a blog in a hard coded you can also refer to this site on how to display your latest tweets in twitter. with twitter API.
    as easy as 1 2 3..

    http://www.ryscript.co.cc/web/how-to-display-latest-tweets-using-javascript-and-twitter-api/

    thanks..

  5. Thank you for the twitter code. I was wondering is there a PHP code that will show the visitor tweeted posts from your blog ?

    that would be a good reward for visitors to tweet your posts.

    thank you for sharing.


2 Trackbacks


Add Your Comment

Gravatar