How To Display External RSS Feeds in WordPress

In our recent post, we wrote about WordPress Feed Tricks, right now we will do something else. Sometimes we have another useful resource about our blog and we need to put the content in the Sidebar. With a little bit of code and a slight tweak, we can do it on our WordPress.

How To Display External RSS Feeds in our WordPress is easy.

There are so many methods to display External Feeds, we can use the RSS Widget, or write our own code. In this tip, we use some WordPress functions.

The first thing is open sidebar.php (if you want to display external RSS content on your sidebar) and write this code below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
require_once (ABSPATH . WPINC . '/rss-functions.php');
// here's where to insert the feed address
$rss = @fetch_rss('http://feeds2.feedburner.com/WPGPL');
if ( isset($rss->items) && 0 != count($rss->items) ) {
?>
<?php
// here's (5) where to set the number of headlines
$rss->items = array_slice($rss->items, 0, 30);
foreach ($rss->items as $item ) {
?>
          <li> <a href='<?php echo wp_filter_kses($item['link']); ?>'> <?php echowp_specialchars($item['title']); ?></a> <spanclass="sdate"><?php echowp_specialchars($item['description']); ?></span> </li>
          <?php } ?>
<?php } ?>

Please note, you need replace RSS feed source with your own resource and then check on your own blogs. In our example, you can check on our sidebar, don’t forget to subscribe to our posts.

If you have little bit of knowledge on CSS and XHTML you can make it a more fancy layout.