Custom Post Type was a great feature introduced with the WordPress 3.0 update. This feature boosted the popularity of the WordPress content management system to a great extent. Being the world’s best CMS, WordPress took forward a great step of making it to the top peak of success. Now, coming to the Custom post types. By default, the custom post types will not be included in the RSS feed of your website. Thus, the users who subscribed to your newsletters won’t get the notifications of that specific post types.
This is a bad situation when the users will not get notified of your latest updates even if they are subscribed to your blog posts. So, this problem must be solved as soon as possible. We prepared an article on “How to add custom post types to main WordPress RSS feed.” to help you in adding the custom post types to your RSS feed.
What is a custom post type?
A custom post type is an additional post type apart from posts, pages, etc. that already comes by default with WordPress. For example, if you are running a news website with WordPress, you may create an additional ‘news’ post type to write news articles separately.
A custom post type can be configured to get all the functionality of a normal post type, such as the post. In addition, you can limit, add, or configure the features for the specific post type.
What is a feed?
A feed is a way for the websites to provide its content to various feed readers for easier access to the latest content published. Even though feeds are not as popular as it used to be, they are still being used by various users and services all across the globe.
Why should you add custom post types to the feed?
By default, WordPress will not include the articles you publish within the custom post types to your website feed. That means, whoever subscribed to your feed and accessed the content using it, will not see those published articles. To fix this problem, you can add additional post types to your WordPress website feed so that they will be treated like normal post types.
How to add custom post type to the feed
To do this, open the functions.php file of your child theme and add the following code within the PHP markup.
function myfeed_request ($qv) {
if (isset($qv['feed']))
$qv['post_type'] = get_post_types();
return $qv;
}
add_filter('request', 'myfeed_request');
This code modifies the feed to keep the current post type (default posts) alongside the custom post type. But, If you have any post types to exclude, you need to tweak the code a little.
function myfeed_request ($qv) {
if (isset($qv['feed']) && !isset($qv['post_type']))
$qv['post_type'] = array('post', 'post_type1', 'post_type2', 'post_type3');
return $qv;
}
add_filter('request', 'myfeed_request');
The above code adds three custom post types to the RSS feed, alongside with keeping the default post type. You need to replace the post_type1, post_type2, and post_type3 with the post types you want to add to your RSS feed. Be sure to keep the post before the custom post types. If you remove it, the default posts will no longer be added to the RSS feed.