Posted By

elijahpaul on 03/28/11


Tagged


Versions (?)

Daniel Hellier Original Display Tweet Code


 / Published in: PHP
 

  1. // Recent tweets function
  2. function recentTweets($username, $number){
  3. include_once(ABSPATH.WPINC.'/rss.php');
  4.  
  5. $tweet = fetch_feed("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" . $number );
  6.  
  7. if (!is_wp_error( $tweet ) ) :
  8. $maxitems = $tweet->get_item_quantity($number);
  9. $rss_items = $tweet->get_items(0, $maxitems);
  10. endif;
  11. if ($maxitems == 0) echo '<li>No Tweets.</li>';
  12. else foreach ( $rss_items as $item ) {
  13.  
  14. $content = html_entity_decode($item->get_content());
  15. $link = html_entity_decode($item->get_permalink());
  16. $date = $item->get_date('l, g:i a');
  17.  
  18. echo "<li>$content <a href='$link'>$date</a></li>";
  19. }
  20. }

Report this snippet  

You need to login to post a comment.