People have different needs for different things, and if your need is to display a simple RSS feed in your theme; there is an easy way to do it… without plugins. There are a lot of plugins out there for displaying an RSS feed, but many of them actually over complicate things. Believe it or not, you already have the ability to parse an RSS feed. Until recently, I had been utilizing RSSImport to accomplish my simple feed requirements, but the fewer plugins we run on our sites, the better.
To display a feed on your site, all you have to do is paste the following code in your theme where you would like the feed to be displayed.
<?php include_once(ABSPATH.WPINC.'/rss.php'); wp_rss('https://computingondemand.com/news/?feed=rss', 20); ?>
Replace the url with the url of the feed you want to parse. Then replace the 20 with the number of titles you wish to show.
You can get a little more complicated if you like and have the ability to add details beyond just the title to your RSS.
<?php include_once(ABSPATH.WPINC.'/rss.php'); wp_rss('https://computingondemand.com/news/?feed=rss', 20); ?>
Replace the url with the url of the feed you want to parse. Then replace the 20 with the number of titles you wish to show.
You can get a little more complicated if you like and have the ability to add details beyond just the title to your RSS.
<ul><?php if(function_exists('fetch_feed')) { include_once(ABSPATH . WPINC . '/feed.php'); // Includes the necessary files $feed = fetch_feed('https://computingondemand.com/news/?feed=rss'); // URL to the feed you want to show $limit = $feed->get_item_quantity(10); // How many items you wish to display $items = $feed->get_items(0, $limit); // 0 is start and limit is noted above } if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>'; else foreach ($items as $item) : ?> <li> <div> <a href="<?php echo $item->get_permalink(); ?>" title="<?php echo $item->get_date('j F Y @ g:i a'); ?>"><?php echo $item->get_title(); ?></a> </div> <div> <?php echo substr($item->get_description(), 0, 400); ?> <p><a href="<?php echo $item->get_permalink(); ?>">[Read More...]</a></p> </div> </li> <?php endforeach; ?><ul>
Note: These functions are not of my own creation, simply things I have found along the way. If you are the author of this function, please let me know so I can properly credit you with your work!
So if I replace the number 20 with zero, will it just show the RSS icon? That’s what I’m attempting to do.
is there a way to add the featured image as a thumbnail on each of the post feeds?
I have not tried, is the image in the rss feed to begin with?