Add Custom Post Types to WordPress RSS feed

By default, WordPress feed only contains your ‘post’ content.  For example http://scottge.net/feed has only my blogs posts.  My ‘product’ (custom post type) content is not in the feed.

1. If you want to have a feed for one custom post type, you can use http://<yourwebsite>.com/feed/?post_type=yourcustomposttype.  For example, http://scottge.net/feed/?post_type=product is the feed of my ‘products’.

2. If you want to include ALL post types in the main site feed (e.g. http://scottge.net/feed), add the following php code to functions.php of your theme.

function my_feed_request($qv) {
if (isset($qv['feed']))
$qv['post_type'] = get_post_types();

return $qv;
}
add_filter('request', 'my_feed_request');

3. If you want to include only certain post types in the main site feed, add the following code to functions.php.

function my_feed_request($qv) {
if (isset($qv['feed']) &amp;amp;amp;&amp;amp;amp; !isset($qv['post_type']))
$qv['post_type'] = array('post', 'product', 'video');

return $qv;
}
add_filter('request', 'my_feed_request');

 

Leave a Reply