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
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).
Now you're ready to display Rss Feeds on your wordpress 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
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).
<?phpStep 3: Use in Your Blog
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;
?>
Now you're ready to display Rss Feeds on your wordpress blog.
Add Comments