Daniel Hellier Original Display Tweet Code


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.