Adding custom post type to your WordPress site is very easy. Plugins like Custom Post Type UI, Types, and WP Easy Post Types can allow you to do so without any coding skill. The problem is that after adding the custom post type, it doesn’t show up in the main RSS feed. Here is a simple tutorial showing you how to include custom post types to your main RSS feed.
To add custom post type content to your RSS feed, you have to add the following code to to the end of the
functions.php file in your theme folder.
Note: Change “post_type_1” to the name of your custom post type.
What the above code does is to change the query options before it goes to the database and fetch the result. In this case, we first check if the query is for a feed output (
$query->is_feed()), and if yes, add the custom post type (“post_type_1”) to the query options. By default, only “Post” is included in the query.
If you need to include multiple custom post types, simply add them into the array, for example:
Getting custom post type to appear in the main page
In addition to include custom post type in RSS feed, you can also use the same method to include custom post type in the Home or Archive page. For this, you have to modify the query condition to the following code:
Image credit: Segnalibri live