By default WordPress only add standard Posts in RSS feed. So when you are using custom post type and creating posts there those will not be added in main RSS feed. But keeping posts in main RSS feed sometimes may increase your visitor and helpful for faster search engine indexing. Here we will show how to add all or specific custom post types in your main RSS feed.

So, If you want include all post types in you main RSS feed, open functions.php from your active theme dir and add following code there:

function wpeden_rsswithcpt($query) {
	if (isset($query['feed']))
		$query['post_type'] = get_post_types();
	return $query;
}
add_filter('request', 'wpeden_rsswithcpt');

in the above code “get_post_type()” function will return the array of all post types including regular post and change the feed query to add other post types as well as regular post. But sometimes you may need to add specific post types with rss feed, in such case, use following code:

function wpeden_rsswithcpt($query) {
	if (isset($query['feed'])  && !isset($query['post_type']))
		$query['post_type'] = array('post','custom-post-type','another-custom-post-type');
	return $query;
}
add_filter('request', 'wpeden_rsswithcpt');

In the code above, “custom-post-type”, “another-custom-post-type” used as sample post type, you need to replace those with your custom post type.


Post Tags


About The Author


Leave a Reply

Your email address will not be published. Required fields are marked *