Download Concise, our LATEST Genesis Framework Child Theme. It's FREE

Download

How to Add Custom Post Types to Main Feed

In our recent project for a client, we needed to include few custom post types we built in the main RSS feed of the site. Specific for that project, we built few custom post types - video, pictures and etc - to make it easier for the client to manage their contents.

However, the default RSS feed for WordPress only includes Post post type. Therefore, every time the client publishes something under the custom post types, those posts won’t be included in the main RSS feed. In other words, readers who subscribed to their RSS won’t be notified with new posts published in those custom post types. This is bad.

1 2 3 4 5 6 7 8
<?php
 
function myfeed_request($qv) {
if (isset($qv['feed']))
$qv['post_type'] = get_post_types();
return $qv;
}
add_filter('request', 'myfeed_request');
view raw functions.php hosted with ❤ by GitHub

The snippet below will add all post types, including any custom post types to your main RSS feed. Thanks to Yoast for this awesome snippet. You may drop the code in functions.php of your child theme or even better, functionality plugin. You may find more information about the code from the Core Trac WordPress.

Leave a Comment

*