Easily add your latest tweets to your WordPress website
There are many Twitter plugins for WordPress but why not create your own ways of displaying your tweets with these 2 simple methods.
Method 1:
<?php
$username = “YOURTWITTERID”;
$prefix = “<h2>My latest tweets</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(“<content type=”html”>”, $feed);
$stepTwo = explode(“</content>”, $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);
?>
Method 2:
Paste this into your functions.php
function wp_echoTwitter($username){
include_once(ABSPATH.WPINC.’/rss.php’);
$tweet = fetch_rss(“http://search.twitter.com/search.atom?q=” . $username . “&amp;rpp=1″);
echo $tweet-&gt;items[0]['atom_content'];
}
Then simply paste this where you want the tweet to display
<?php wp_echoTwitter(‘YOURTWITTERID’); ?>
Obviously replace YOURTWITTERID with yours and then style with CSS as you desire.
Related Posts
2 Comments + Add Comment
WordPress support
Wordpress Themes & plugins
WordPress Books
- Underground Twitter Secret Manifesto
- Smashing WordPress: Beyond the Blog (Smashing Magazine Book Series)
- Wie Tipps zum Erstellen eigener Webauftritt (German Edition)
- No Business Like E-Business: The Spectacularly Simple Secrets Behind How You Can Create A Web Site And Make Money With It
- WordPress Power Guide To Great 100 Plugins
- WordPress Websites for Writers Reviews
- Affiliate Site Marketing, Backlink Strategies & Long-Term Training (Supertargeting Affiliate Training)
- Sams Teach Yourself WordPress 3 in 10 Minutes (Sams Teach Yourself — Minutes)
- The Best Little Book On Selecting Your Mommy Blogging Platform
- WordPress: Visual QuickStart Guide, ePub
- WordPress Website Secrets: How to Use WordPress to Build Killer Websites
- Mastering Google Plus One For Business
- Logo Design Love: A Guide to Creating Iconic Brand Identities (Voices That Matter)
- All About Blogging
- WordPress For Dummies







[...] This post was mentioned on Twitter by Lee Rickler, Space Spare, Lee Rickler, Lee Rickler, Point and Stare and others. Point and Stare said: RT @londonwordpress: Latest: Easily add your latest tweets to your WordPress website http://bit.ly/aKuy2S [...]
Good read, I really enjoyed reading it. Thanks for posting, it’ll be valueable in the future for me!