Display RSS Feed on Your WordPress Blog

Advertisemen
Are you want to Display RSS Feed on Your WordPress Blog and got some problem . Then this simple code is the only solution to display feed of many website on your blog.
Here’s a simple code that will do the job without using the deprecated wp_rss() function.

Step 1: Get the feed url of website 
First of all you need to get the Feed URL of that website which feeds you want to display.
You can take TechDilute feed : http://feeds.feedburner.com/techdilute

Display RSS Feed on Your WordPress Blog,How to display RSS feeds on your WordPress blog,RSS feeds on your WordPress blog,wordpress feed,rss feed with wordpress

Step 2: Replace the feed url in following code

Don't forget to update the feed url (Red).
Number of items to be displayed (Blue).
<?php
include_once(ABSPATH . WPINC . '/rss.php');
$feed = 'http://example.com/feed/';
$rss = fetch_feed($feed);
if (!is_wp_error( $rss ) ) :
    $maxitems = $rss->get_item_quantity(3);
    $rss_items = $rss->get_items(0, $maxitems);
    if ($rss_items):
        echo "<ul>\n";
        foreach ( $rss_items as $item ) :
            echo '<li>';
            echo '<a href="' . $item->get_permalink() . '">' . $item->get_title() . "</a>\n";
            echo '<p>' . $item->get_description() . "</li>\n";
        endforeach;
        echo "</ul>\n";
    endif;
endif;
?>
Step 3: Use in Your Blog
Now you're ready to display Rss Feeds on your wordpress blog.
Advertisemen