Work@Microsoft    Study@UW.edu    Live@Seattle

Add Custom Post Types to WordPress RSS feed

Add Custom Post Types to WordPress RSS feed
5 (100%) 1 vote

By default, WordPress feed only contains your ‘post’ content.  For example http://scottge.net/feed has only my blogs posts.  My ‘resume’ (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=rb_resume is the feed of my ‘resumes’.

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 Comment

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

Loading...
ScottGe.net