Control the RSS Feed on Your WordPress Site Like a Pro

Ogi Djuraskovic
Updated: October 4th, 2023
7 min read
FirstSiteGuide is supported by our readers. When you purchase via links on our site we may earn a commission. Read More
Control the RSS Feed on Your WordPress Site Like a Pro

If you have created a website powered by WordPress, the chances are that you’re are going to publish new content on a daily basis or at least weekly. If so, you will want to hand out your content to users.

While many of them will get updates from your site through the site itself and the social media pages you create, you shouldn’t forget about the RSS feed.

Rich Site Summary or Really Simple Syndication is designed to show frequent content and deliver it to a broad audience. RSS document which is known as a ‘feed’ consists of a title followed by a small excerpt, an image or different extra information about the posts, website, author, etc.

WordPress automatically creates a feed for your website, and you can easily see it on www.yourdomain.com/feed.

No, feeds aren’t dead yet, and there are millions of users worldwide. So, the chances are that your visitors use different aggregators on their computers or smartphones to get news from your site. Because of that, it’s in your interest to make the RSS feed as best as possible.

Add any RSS feed to your dashboard

By default, WordPress displays the RSS feed on your dashboard. Obviously, this feed contains news which aren’t interesting to everyone. Instead of leaving it like that, you can completely customize your dashboard and remove the feed, or you can customize only the feed and add stuff that really matters to you.

Without any further ado, we are about to show you how to change WordPress feed and add a custom link that you will actually care of:

  • Navigate to functions.php file and open it
  • Copy and paste this code:
function wpc_dashboard_widgets() {
global $wp_meta_boxes;
// remove unnecessary widgets
// var_dump( $wp_meta_boxes['dashboard'] ); // use to get
all the widget IDs
unset(
$wp_meta_boxes['dashboard']['normal']['core']
['dashboard_plugins'],
$wp_meta_boxes['dashboard']['side']['core']
['dashboard_secondary'],
$wp_meta_boxes['dashboard']['side']['core']
['dashboard_primary']
);
// add a custom dashboard widget
wp_add_dashboard_widget( 'dashboard_custom_feed', 
'WP Loop', 'dashboard_custom_feed_output' ); 
//add new RSS feed output
}

function dashboard_custom_feed_output() {
echo '<div class="rss-widget">';
wp_widget_rss_output(array(
'url' => 'https://firstsiteguide.com/feed',
'items' => 5,
'show_summary' => 1,
'show_author' => 0,
'show_date' => 1
));
echo "</div>";
}

add_action('wp_dashboard_setup', 
'wpc_dashboard_widgets');




  • Change parameters which you want
  • Save changes

If you’re not into coding, don’t be scared by all that you see above. Customizing the code so that you can add RSS feed which you really want is only a few steps away.

Let’s start with the most important part, and that is the RSS feed address. Simply find the following line of code in the above function and change the URL:

'url' => 'http://www.yourrssfeed.com/feed'




Now that you have located the line and changed the address, you can slowly continue reading out the code. For starters, change the number of news that you want to appear in your feed. Summary, author, and date can have only “1” or “0” values which means that you do want or don’t want to show summary, author’s name, and you guessed – date of publishing.

Last but not least, you will probably want to change the title of your RSS feed. If so, find the following line in the function you have c/p just a moment ago and change the title:

wp_add_dashboard_widget( 'dashboard_custom_feed', 
'TITLE GOES HERE', 'dashboard_custom_feed_output' ); 
//add new RSS feed output

Don’t forget to save the changes and navigate to your dashboard. If everything is done correctly, your custom news feed is ready; cool, isn’t it?

How to easily display any external RSS feed

While you can easily show your own RSS feed simply by redirecting users to a link on your WordPress website, showing an external link could be a little bit more complicated. But don’t let that discourage you because you can still have an RSS feed displayed anywhere on your site just by copy/pasting a function which we’re going to show you in this article.

Instead of installing another plugin which will take control over the feeds and will require constant care and updates, you can create your own list. All you will have to do is change a link to the feed you want to display and modify the number of feeds shown on your site.

Whether you are going to show external RSS feed on a new page/post or you want to nest it in your sidebar, header or footer the procedure is practically the same:

  • Open sidebar.php file or any file where you want the feed to show up
  • Copy and paste the following code:
<?php include_once(ABSPATH.WPINC.'/feed.php');
$rss = fetch_feed('http:// 
http://dev.firstsiteguide.com/feed/');
$maxitems = $rss->get_item_quantity(4);
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul>
<?php if ($maxitems == 0) echo '<li>No items.</li>';
else
// Loop through each feed item and display each item as
a hyperlink.
foreach ( $rss_items as $item ) : ?>
<li>
<a href='<?php echo $item->get_permalink(); ?>'
title='<?php echo 
'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
<?php echo $item->get_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>




  • Change the URL on line #2
  • Change number of RSS feeds which will be displayed on line #3
  • Save changes

Now that you have set up one or several RSS feeds from other sites, don’t forget to take care of your own RSS feeds.

Enable images in RSS feeds; it’s easier than you think

Many people think that RSS feeds are part of history. Yet, even more, people use RSS on a daily basis. Not only can you have your favorite websites stored in your browser, on your website or even in your WordPress admin, feeds got even more popular once smartphones took over the world. Now you can keep tracking updates from your favorite updates and authors on the go and have access to new content in seconds after a new article has been published.

Even if you’re still not into RSS feeds, once you start running your own website, you should think of those who regularly use this service.

rss feed

There are different ways of manipulating RSS content in WordPress. For example, you can schedule your post for RSS feeds or you can change the way WordPress shows excerpts that effect RSS feeds as well. But no matter what you do, you still won’t have a picture attached to your RSS feed.

Imagine yourself having several websites on the same topic that regularly update their feeds. You open up your feed app (Feedly for example) on your smartphone and there is a site with an image next to the post title, while the other has no images. In almost all cases, people will go to the link with the picture next to it because that one seems more interesting and it gives you the feeling that the author cares about his stuff.

Since you already have a featured images attached to each post, there’s no excuse – you can have that image attached to RSS feed as well and make your website more attractive to people who use feeds.

In this part of the guide, we’re about to show you how to add featured image to your feeds. Actually, it is very simple and you will only have to copy and paste the code found below:

  • Open functions.php file
  • Copy and paste the code:
add_filter('the_content_feed', 'rss_post_thumbnail');
function rss_post_thumbnail($content) {
global $post;
if( has_post_thumbnail($post->ID) )
$content = '<p>' . get_the_post_thumbnail($post->ID,
'thumbnail') . '</p>' . $content;
return $content;
}




  • Save changes

There you go. Each post that has a featured image attached to it will now use the same image as an addition to RSS feeds. Now you can go on and try your updated RSS feed in any application you might be using. Instead of boring and plain text, you will have an image which changes the entire presentation of your site.

Schedule your posts for RSS in 5 simple steps

Usually, WordPress will post your new article in the RSS feed automatically after you hit the publish button. While there’s nothing wrong with it and you actually want your article to appear in the feed as soon as possible, sometimes you might want to schedule that post. In this part of the article, we will show you how to delay an RSS post. Just for example, if you delay the post for a few minutes, it will be just enough for you to make some additional changes before the post is posted in the feed.

Here’s the code that you will need in order to achieve this delay:

  • Open functions.php file
  • Rewrite the code word for word…or copy and paste the code, of course:



function scheduled_feed($where) {
global $wpdb;
 
if ( is_feed() ) {
// timestamp in WP-format
$now = gmdate('Y-m-d H:i:s');

// value for wait; + device
$wait = '10'; // integer

// http://dev.mysql.com/doc/refman/5.0/en/date-and-time
-functions.html#function_timestampdiff
$device = 'MINUTE'; //MINUTE, HOUR, 
DAY, WEEK, MONTH, YEAR

// add SQL-sytax to default $where
$where .= " AND TIMESTAMPDIFF($device, $wpdb->
posts.post_date_gmt, '$now') > $wait ";
}

return $where;
}

add_filter('posts_where', 'scheduled_feed');
  • Change $device variable into minutes, hours, days and so on
  • Change $wait variable into the number of minutes, hours, days or whatever you have chosen. This is the time your post will wait before it gets automatically published in RSS Feed
  • Save changes

That’s it. You don’t have to do anything else to schedule your RSS feed.

Automate your post’s RSS Feed

Automate your RSS feed output with web push notifications. Easily integrate your web push notifications to automatically post your RSS feed items through targeted web push notifications.

The easiest way to exclude categories from RSS feed

From the moment when you publish your first post using WordPress, your new posts will automatically be published as RSS feed. That feed can be easily accessed by any user who wants to follow your website, and because of that, you need to make your RSS feed as good as it can get.

RSS Feed

While you can easily postpone publication of your feeds by anytime you want, sometimes you will need to show only specific categories to your followers. Better yet, you will want to exclude those categories that you don’t want to be displayed in the feed.

Easily exclude categories from RSS feed:

For example, you might have a dozen categories that are being updated with new content on a daily basis and you don’t want to overwhelm your users. Maybe a specific category is designed only to draw in users from social media sites. Or maybe you want your RSS feed only to show category “news”. Whatever the reason, in the following lines we’re about to show you how to easily exclude a category from RSS feed:

  • Open functions.php
  • Copy and paste the code:
function exclude_categories_from_rss($query) {
if ($query->is_feed) {
$query->set('cat','-10,-21,-32');
}
return $query;
}
add_filter('pre_get_posts',
'exclude_categories_from_rss');




  • Change category ID’s on the 3rd line
  • Save changes

The easiest way of finding a category’s ID number is opening a category from Posts -> Categories. Once you click on “Edit” button, the ID will be shown on top of your browser in a form of URL.

As you can notice from the code, to exclude a category you will need to enter a “-“ character before the ID. Once you set the IDs, those categories will no longer be displayed in your RSS feed. If you need to change that in the future, you can simply change the function when needed and add/remove a category from the list.

Your RSS feed has just become even better. Don’t forget to check our other tutorials on how to improve your WordPress-powered website and make the best of the already great blogging platform.

Wrapping up

By now, you should have accepted the fact that RSS feeds are still a thing. And even if you’re not a fan of RSS, you should think of your visitors who still use feeds on a daily basis. To help them out, make the best out of your RSS feed by implementing any of the tips we showed you in this guide.

What do you think about RSS? Do you aggregate news on your computers or smartphones? What about RSS on your blog?

Leave a Reply

Your email address will not be published. Required fields are marked *

Send this to a friend