WordPress RSS feeds display your recent post content by default, and there is no way to change that information for RSS feed subscribers.
We’ll teach you how to simply add content and entirely manage your WordPress RSS feeds in this article.
The All in One SEO for WordPress plugin is the simplest method to add custom content to your WordPress RSS feeds. It’s the greatest WordPress SEO plugin on the market, and it makes optimizing your website’s SEO a breeze.
The All in One SEO for WordPress plugin must first be installed and activated. See our step-by-step guide on installing a WordPress plugin for more information.
You will be required to set up the plugin after activation. Simply follow the on-screen instructions, or read our guide on installing All in One SEO for WordPress.
After that, go to All in One SEO » General Settings and select the RSS Content tab from the drop-down menu.
You can add information to appear before and after each RSS feed item from this page. Smart tags can be used to add links and other metadata to custom content.
You can format your custom material in any way you like using simple HTML.
Don’t forget to click the Save Modifications button once you’re happy with the changes.
Each RSS feed item will now have your custom content added to it by All in One SEO.
The first option is the simplest method for adding custom content to your WordPress RSS feeds. It, on the other hand, adds the content to all of the items in your WordPress feed.
What if you wanted to include custom metadata in your RSS feed, or add content to certain posts or categories?
The following steps will show you how to use custom code snippets to add material to your RSS feed in a flexible manner.
You can use the custom Code Snippets plugin, a functions.php file, or a site-specific WordPress plugin to add these code snippets to your website.
Let’s look at some manual instances of adding custom content to WordPress RSS feeds.
You may use custom fields to add more metadata to your WordPress posts and pages. However, RSS feeds do not provide this metadata by default.
Here’s a sample for getting custom field data from your WordPress RSS feed and displaying it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
function wpb_rsstutorial_customfield( $content ) { global $wp_query ; $postid = $wp_query ->post->ID; $custom_metadata = get_post_meta( $postid , 'my_custom_field' , true); if (is_feed()) { if ( $custom_metadata !== '' ) { // Display custom field data below content $content = $content . "<br /><br /><div>" . $custom_metadata ."</div> "; } else { $content = $content ; } } return $content ; } add_filter( 'the_excerpt_rss' , 'wpb_rsstutorial_customfield' ); add_filter( 'the_content' , 'wpb_rsstutorial_customfield' ); |
This code first checks if the custom field contains data before displaying the RSS feed. The content global variable is then appended, and custom field data is added underneath the content.
Do you want to add more text to the titles of some of your RSS feed posts? You could want to make a distinction between regular articles and sponsored or guest content.
Here’s how to add custom information to your RSS feed’s post titles.
To begin, save the content that you wish to display as a custom field. You can add custom fields like guest post and sponsored post, for example.
After that, you may paste the code below into your website.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
function wpb_rsstutorial_addtitle( $content ) { global $wp_query ; $postid = $wp_query ->post->ID; $gpost = get_post_meta( $postid , 'guest_post' , true); $spost = get_post_meta( $postid , 'sponsored_post' , true); if ( $gpost !== '' ) { $content = 'Guest Post: ' . $content ; } elseif ( $spost !== '' ){ $content = 'Sponsored Post: ' . $content ; } else { $content = $content ; } return $content ; } add_filter( 'the_title_rss' , 'wpb_rsstutorial_addtitle' ); |
This code merely searches for custom fields. If they aren’t empty, the custom field’s value is appended to the post title in your RSS feed.
In this case, the category name will be displayed in the post title.
Simply paste the code below into your website:
1
2
3
4
5
6
7
8
9
|
function wpb_rsstutorial_titlecat( $content ) { $postcat = "" ; foreach ((get_the_category()) as $cat ) { $postcat .= ' (' . $cat ->cat_name . ')' ; } $content = $content . $postcat ; return $content ; } add_filter( 'the_title_rss' , 'wpb_rsstutorial_titlecat' ); |
In the RSS feed, categories will now appear alongside post titles. “Top New Restaurants in Bay Area (News) (Travel),” for example, where News and Travel are both categories.
Let’s say you want to add custom material to specific tags or categories, but only for those posts.
The code below will allow you to simply add material to posts that are organized by categories and tags.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
function wpb_rsstutorial_taxonomies( $content ) { if ( is_feed() ){ // Check for posts filed under these categories if ( has_term( array ( 'travel' , 'news' ), 'category' ) ) { $content = $content . "<br /><br />For special offers please visit our website" ; } } return $content ; } add_filter( 'the_excerpt_rss' , 'wpb_rsstutorial_taxonomies' ); add_filter( 'the_content' , 'wpb_rsstutorial_taxonomies' ); |
This code can be tweaked to target tags as well as custom taxonomies. Here’s an example of a specific tag being targeted:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
function wpb_rsstutorial_taxonomies( $content ) { if ( is_feed() ){ // Check for posts filed under these categories if ( has_term( array ( 'holidays' , 'blackfriday' ), 'post_tag' ) ) { $content = $content . "<br /><br />For special offers please visit our website" ; } } return $content ; } add_filter( 'the_excerpt_rss' , 'wpb_rsstutorial_taxonomies' ); add_filter( 'the_content' , 'wpb_rsstutorial_taxonomies' ); |
Featured photos for posts are not displayed in your WordPress RSS feed by default. Featured photos can be manually added to your RSS feed to change this.
1
2
3
4
5
6
7
8
9
10
|
function wpb_rsstutorial_featuredimage( $content ) { global $post ; if (has_post_thumbnail( $post ->ID)) { $content = '<p>' . get_the_post_thumbnail( $post ->ID) . '</p>' . get_the_content(); } return $content ; } add_filter( 'the_excerpt_rss' , 'wpb_rsstutorial_featuredimage' ); add_filter( 'the_content_feed' , 'wpb_rsstutorial_featuredimage' ); |
This code just checks for a thumbnail (featured picture) in a post and shows it alongside the rest of the content.
Additional Resources for Customizing RSS Feeds in WordPress
RSS feeds can be a useful tool for attracting new subscribers and keeping existing ones engaged. The resources listed below will assist you in further optimizing your WordPress feeds.
We hope this post has shown you how to update your WordPress RSS feeds with new information. You might also be interested in our articles on how to attract more free traffic to your website by adding email subscribers to your WordPress blog.