By Neil on May 28, 2014
Custom post types are a fantastic way to sort your websites content and to make life easier for yourself by having set post types for set bits of content. However, these custom post types do not show in your websites feed (RSS feed) by default, which can impact on your websites potential reach and readership. You can see your websites feed by typing yourwebsitename.com/feed into the URL.
This is pretty easy to sort out though, and with some code added to your websites functions.php file you can get all your custom posts showing in your feed. The video below walks through the entire process, but also see the explanation below.
Step-by-step tutorial to show custom posts in your feed
Make a note of the slug of your custom post types because this is what you need to refer to in the code we are going to add to the functions.php file. You specified this slug when you set up your custom post type, but you can also easily see it by viewing one of your custom posts and looking at its URL. E.G. www.yourwebsitename.com/custom-post-type-slug/post-title.
In your WordPress dashboard open up the editor screen for your functions.php file. This is found under Appearance/editor and click on the file on the right-hand-side that says function.php (may be called Theme Functions).
Scroll to the bottom of the functions.php code and add the following:
//* Add custom post types to RSS feed
function myfeed_request($qv) {
if (isset($qv[‘feed’]) && !isset($qv[‘post_type’]))
$qv[‘post_type’] = array(‘custom-post-type-slug’, ‘another-custom-post-type-slug1’, ‘another-custom-post-type-slug2’);
return $qv;
}
add_filter(‘request’, ‘myfeed_request’);
The //* comments out this top line because it is there for reference. Replace custom-post-type-slug with your slug. You can specify several custom post types here.
Update these changes and you are done. Check your feed and your should see all of you custom posts showing up.
Leave a Reply