How to Add Custom Post Types to Your Main WordPress RSS Feed

Recently, I was checking the RSS feed of my news blog Techlomedia and found that its review articles were not there. Then I tried to figure out the reason and got to know why this was happening. WordPress never includes Custom Post types in the main RSS feed. It only includes Posts. There is a separate feed for the custom post types. It can be accessed at: http://example.com/feed/?post_type=yourposttype. So, accessing the main feed of the blog will not show you the links to custom post-type articles.
Also see: WordPress.org vs WordPress.com
Best Managed WordPress Hosting
WPEngine is the best and most secure managed hosting providerIf you are using Custom Post Types and want to include those articles in the main RSS feed, you need to do a little code modification. There could be several reasons for doing this. I was doing this because I have set up an RSS-driven emailing system and it was missing my custom posts.
In this article, I will share how you can add Custom Post Types to your main WordPress RSS feeds.
Add Custom Post Types to Your Main WordPress RSS Feed
For this, you need to edit the functions.php file of your WordPress theme. Open that file and add the code given below.
function myfeed_request($qv) {
if (isset($qv['feed']))
$qv['post_type'] = get_post_types();
return $qv;
}
add_filter('request', 'myfeed_request');
This will include all your custom posts in the main RSS feed. But what if you want to include only selected Custom Post Types but not all? For this, you can use the code below.
function myfeed_request($qv) {
if (isset($qv['feed']) && !isset($qv['post_type']))
$qv['post_type'] = array('post', 'story', 'books', 'movies');
return $qv;
}
add_filter('request', 'myfeed_request');
Try these codes to add your custom post types to the main RSS feed of your blog.
Final Words
This is very important if you are using a custom post type. RSS feed gives good exposure and traffic. If a person has subscribed to your blog’s RSS feed, he is interested in getting all your updates. But default WordPress settings do not allow the RSS feed to deliver your custom post type. So, do not forget to include your custom post type in the main RSS feed of your blog.
Try this way and let me know if you have anything to ask.
Leave a comment
Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted.