How To Display Your Latest Twitter Entries on WordPress

Jauhari

8 comments

Link

Today, Twitter is the most successfully microblogging website on this planet, Twitter was adopted on search result in Google, Bing and Yahoo. Beside that fact, mostly twitter user also ordinary blogger like me, they have personal blog or business blog. With a little trick that I got from instanshift, we can integrated our latest tweets on our WordPress blog.

twitter-white

This code is really useful and I was tried on my blog run without any worries. How to display latest twitter entries on WordPress is, copy and paste this code on your sidebar.php or footer.php or anywhere else and replace $username variable with your username.

[sourcecode language=”php”]
<?php
$username = "<a title="jauhari" href="http://www.jauhari.net/category/jauhari">jauhari</a>"; // Your twitter username.
$limit = "3"; // Number of tweets to pull in.

/* These prefixes and suffixes will display before and after the entire block of tweets. */
$prefix = ""; // Prefix – some text you want displayed before all your tweets.
$suffix = ""; // Suffix – some text you want displayed after all your tweets.
$tweetprefix = ""; // Tweet Prefix – some text you want displayed before each tweet.
$tweetsuffix = "<br>"; // Tweet Suffix – some text you want displayed after each tweet.

$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" . $limit;

function parse_feed($feed, $prefix, $tweetprefix, $tweetsuffix, $suffix) {

$feed = str_replace("&lt;", "<", $feed);
$feed = str_replace("&gt;", ">", $feed);
$feed = str_replace("&gt;", ">", $feed);
$feed = str_replace("&quot;", "’", $feed);
$clean = explode("<content type="html">", $feed);

$amount = count($clean) – 1;

echo $prefix;

for ($i = 1; $i <= $amount; $i++) {
$cleaner = explode("</content>", $clean[$i]);
echo $tweetprefix;
echo $cleaner[0];
echo $tweetsuffix;
}

echo $suffix;
}

$twitterFeed = file_get_contents($feed);
parse_feed($twitterFeed, $prefix, $tweetprefix, $tweetsuffix, $suffix);

?>
[/sourcecode]

This tips was writen by Andres Ross on InstanShift

Share:

Related Post

8 responses to “How To Display Your Latest Twitter Entries on WordPress”

  1. RT @jauhari How To Display Your Latest Twitter Entries on WordPress http://bit.ly/8DbiIm

  2. MasEDI Belajar NgeBlog Avatar

    nice tip i’ll try it, thank you

  3. skyreth Avatar

    om jauhari..kata teman saya klo auto post status di twiter ntar follower nya berkurang? benar ya ?

    1. Jauhari Avatar

      Saya rasa ndak juga mas 🙂

  4. 2mk Avatar

    Ap gak enakan pakai simplexml mas ?

  5. @HeriNXI bisa make Widgetnya Twitter.com atau make ini mas http://bit.ly/7Gp4BQ

  6. Elle Wood Avatar

    I can certainly use this. Thank you!

  7. […] a pluginDisplay your tweets without a pluginMost Wanted Twitter Hacks and Plugins for WordPressHow To Display Your Latest Twitter Entries on WordPressHow To Display Twitter counter in TextSocial Bookmarking Link Codes for 33 of the BiggestCreating […]

Leave a Comment