Do you want to add custom post types to your main WordPress RSS feed?

By default, the WordPress RSS feed only shows your recent blog posts. However, if you are using custom post types for other content, then you may want to include them in your main RSS feed as well.

In this article, we’ll show you how to easily add custom post types to your main WordPress RSS feed.

Why Add Custom Post Types to Main RSS Feed in WordPress?

By default, WordPress comes with two commonly used content types called posts and pages. However, you can also create custom post types to add more content types if needed.

For instance, a movie review website may want to create a custom post type for movie reviews using custom taxonomies suitable for that particular content type.

Now, your custom post types can have their own RSS feed which users can access by adding /feed/ at the end of the custom post type archive URL.

https://example.com/custom-post-type/feed/
https://example.com/movies/feed/

However, the custom post-type feeds are not easily discoverable. If a user enters your website’s URL in their feed reader, then it will show the subscription option for your main WordPress RSS feed.

That being said, let’s see how to easily fix that by adding custom post type to your main WordPress RSS feed.

Adding All Custom Post Types to Your WordPress RSS Feed

This method allows you to add all publicly available post types to be included in your main WordPress RSS feed.

You’ll need to add code to your WordPress website. If you haven’t done this before then take a look at our guide on how to easily add custom code snippets in WordPress.

Simply copy and paste the following code to your theme’s functions.php file or a site-specific plugin.

function myfeed_request($qv) {
if (isset($qv[‘feed’]))
$qv[‘post_type’] = get_post_types();
return $qv;
}
add_filter(‘request’, ‘myfeed_request’);

This code simply modifies the default WordPress query to fetch RSS feeds by adding all publicly visible post types into the query.

This will allow you to add pages as well as all other custom post types into your main WordPress RSS feed.

Adding Specific Custom Post Types in Main WordPress RSS Feed

This method is more flexible and allows you to choose which post types you want to include into your main WordPress RSS feed.

Simply copy and paste the following code into your WordPress website.

function myfeed_request($qv) {
if (isset($qv[‘feed’]) && !isset($qv[‘post_type’]))
$qv[‘post_type’] = array(‘post’, ‘movies’, ‘books’);
return $qv;
}
add_filter(‘request’, ‘myfeed_request’);

You can now visit your WordPress RSS feed to see this code in action.

We hope this article helped you add custom post types to your main WordPress RSS feed. You may also want to see our tips to optimize WordPress RSS feeds or see these best WordPress RSS feed plugins for bloggers.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Add Custom Post Types to Your Main WordPress RSS Feed first appeared on WPBeginner.