As a WordPress developer with over a decade of experience building custom CMS solutions, I've relied on Custom Post Types (CPTs) since their introduction in WordPress 3.0. They transformed WordPress into a versatile content management powerhouse. If you're using CPTs, you might want to include them in your main RSS feed—which by default only covers standard posts, excluding even pages.
To achieve this, add the following code to your theme's functions.php file. This snippet modifies the feed query to incorporate all post types while preserving the default 'publish' status for posts:
function myfeed_request($qv) {
if (isset($qv['feed'])) {
$qv['post_type'] = get_post_types();
}
return $qv;
}
add_filter('request', 'myfeed_request');This ensures your main RSS feed includes everything seamlessly.
Need more control, like including only specific CPTs out of several? For instance, if you have five CPTs but want just three in the feed, tweak the array like this example (showing posts, stories, books, and movies):
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');Simply customize the array to match your desired post types. This approach is reliable, drawn from WordPress Core Trac Ticket #12943.