This is just a little snippet that I wrote last night and decided to share. Basically, what it does is takes the latest tweet from someone's twitter account and posts the text on your wordpress post or page.
In order to use this, you need to:
1. Add this code to your functions.php file within wordpress, making sure it's within the php section.
2. When you want to display the tweet, use the code [twitter pro="pokerprosnamehere"] within your post or page.
I think this could be useful on a profile type page, as one example. Oh, and if you want to display more than one tweet, change count=1 to whatever number, up to 200.PHP Code:function get_twitter($atts, $content = null) {
extract(shortcode_atts(array(
'pro' => 'no foo',
), $atts));
require_once(ABSPATH . 'wp-includes/class-snoopy.php');
$snoopy = new Snoopy;
$atts = $atts['pro'];
$snoopy->fetch("http://twitter.com/statuses/user_timeline/$atts.json?count=1");
$twitterdata = json_decode($snoopy->results,true);
echo $twitterdata[0]["text"];
}
add_shortcode('twitter', 'get_twitter');













LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks