Show Your Favorite Tweets with WordPress


SUBMITTED BY: phpsnippets

DATE: Oct. 22, 2015, 3:31 p.m.

FORMAT: Text only

SIZE: 586 Bytes

HITS: 1050

  1. <?php
  2. include_once(ABSPATH . WPINC . '/feed.php');
  3. $rss = fetch_feed('http://twitter.com/favorites/793830.rss');
  4. $maxitems = $rss->get_item_quantity(3);
  5. $rss_items = $rss->get_items(0, $maxitems);
  6. ?>
  7. <ul>
  8. <?php if ($maxitems == 0) echo '<li>No items.</li>';
  9. else
  10. // Loop through each feed item and display each item as a hyperlink.
  11. foreach ( $rss_items as $item ) : ?>
  12. <li>
  13. <a href='<?php echo $item->get_permalink(); ?>'>
  14. <?php echo $item->get_title(); ?>
  15. </a>
  16. </li>
  17. <?php endforeach; ?>
  18. </ul>

comments powered by Disqus