
If you’re using Twitter, you maybe want to display your latest tweets on your blog. You can use a plugin for that, or you can use this code to display your tweets without using any plugin.
This is a function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | function am_twitter_feed($username, $limit = 5 ) { include_once(ABSPATH . WPINC . '/feed.php'); $rss = fetch_feed('https://api.twitter.com/1/statuses/user_timeline.rss?screen_name='.$username); if ( is_wp_error( $rss ) ) return '<li>No tweets</li>'; $maxitems = $rss->get_item_quantity($limit); $rss_items = $rss->get_items(0, $maxitems); $html = ''; if ($maxitems > 0) : foreach ( $rss_items as $item ) : $html .= '<li><a href="'.$item->get_permalink().'">'.$item->get_title().'<br />'.$item->get_date().'</a></li>'; endforeach; endif; return $html; } |
Run this function like this:
1 2 3 | <ul> < ?php echo am_twitter_feed('crazyxhtml', 5 ); ?> </ul> |
Read more how to integrate Facebook, Twitter and Google+ in WordPress: http://wp.smashingmagazine.com/2012/01/19/facebook-twitter-google-wordpress/

