How to add custom post types to your main WordPress RSS feed?

Would you like to learn to add custom post types to your main WordPress RSS feed?

This WordPress By default, RSS feeds show only recent posts. You may already be using custom post types for other content that you may want them to include in your main RSS feed. Additionally, RSS feeds can be tied to custom post types, but unlike posts and comments, it is not automatically generated.

Find the feed address for the custom post type key in your website’s URL. For example, if only the website https://www.food.com/ had a custom post type called “Katti roll”, the feed would look like https://www.food.com/feed/?post_type=Katti roll.

In this article, we mentioned the easiest way to add custom post types to your main WordPress RSS feed.

Add all custom post types to your main WordPress RSS feed

This method will add all publicly available post types to the main RSS feed. The process is simple, you just need to add the code to your functions.php file. However, be careful when adding code, small mistakes can bring down the entire system.

You can read our other article “How to easily add custom code in WordPress?” to help you solve the problem of adding code in the functions.php file. Copy and paste the code mentioned below into the theme’s functions.php file:

function myfeed_request($qv) {

if (isset($qv[‘feed’]))

$qv[‘post_type’] = get_post_types();

return $qv;

}

add_filter(‘request’, ‘myfeed_request’);

Additionally, the code can add all publicly available posts to the RSS feed by modifying the default WordPress query. This code allows adding pages as well as all other custom post types.

Add specific custom posts to your main WordPress RSS feed

Basically, this method is for people who just want to show special posts in their RSS feed. You need to select and mention it in the code. Without a doubt, you have to copy the code mentioned below into your function.php file:

function myfeed_request($qv) {

if (isset($qv[‘feed’]) && !isset($qv[‘post_type’]))

$qv[‘post_type’] = array(‘keywords’, ‘slugs’, ‘tags’);

return $qv;

}

Add custom post types to your main WordPress RSS feed.

Replace the array: keywords, slugs, tags with your post. So save your changes and activate the code. Head over to your RSS feed and note the changes you’ve made.

wrap up

Finally, we hope this tutorial was helpful and cleared up all your doubts about custom post types. Also, you can read our article “How to Limit the Number of Posts in a WordPress RSS Feed?” for more information on this topic.

Leave a Comment