How to display RSS feeds on WordPress
If you ever want to display any rss feed on your WordPress blog then follow the process. The simple code that will do the job without using the deprecated wp_rss() function in wordpress.
The following code you have to paste in template pages wherever you wanna display the rss feed.
Please update the feed url on line 3. and the Number of items you want to display can be defined on line 6.
If you ever want to display any rss feed on your WordPress blog then follow the process. The simple code that will do the job without using the deprecated wp_rss() function in wordpress.
The following code you have to paste in template pages wherever you wanna display the rss feed.
Please update the feed url on line 3. and the Number of items you want to display can be defined on line 6.
<?php include_once(ABSPATH . WPINC . '/rss.php'); $feed = 'http://sandipdas.in/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; ?>
No comments:
Post a Comment