How to Add Custom Post Types to Your Main WordPress RSS Feed?

0
34

Do you want to learn to add custom post types to your main WordPress RSS feed?

The WordPress RSS feed displays only the recent posts by default. You might have used custom post types for other content you would probably want them to include in your main RSS feed. Additionally, RSS feeds can be tied to Custom Posts Types, but it is not automatically generated unlike for posts and comments. 

For the finding of the feed address for your Custom Posts Type key in the URL of your website. for instance, if only website https://www.food.com/ had a custom post type called “Katti roll” then the feed will look like https://www.food.com/feed/?post_type=Katti roll. 

 In this article, we have mentioned the easiest way to add custom post types to your main WordPress RSS feed.

Addition of all Custom Post Types to Your Main WordPress RSS Feed 

This method will add all publicly available post types to the main RSS feed. The process is simple all you need to do is add the code into your functions.php file. But, be careful while adding code small error causes the breakdown of the entire system.

You can go through our other article ”How to Easily Add Custom Code in WordPress?” to help you out regarding the addition of codes in the functions.php file. Copy and paste the code mentioned below into your functions.php file of your theme:

function myfeed_request($qv) {

if (isset($qv[‘feed’]))

$qv[‘post_type’] = get_post_types();

return $qv;

}

add_filter(‘request’, ‘myfeed_request’);

Add Custom Post Types to Your Main WordPress RSS Feed.

Moreover, the code functions to add all the publicly available posts to the RSS feed by modifying the default WordPress query. The addition of pages as well as all other custom post types are permitted by this code.

Addition of Specific Custom Posts to Your Main WordPress RSS Feed 

Basically, the method is for the one who only wants to display special posts to the RSS feed. You need to choose and mention it in the code. Without a doubt, you have to copy the code mentioned below into your function.php file:

function myfeed_request($qv) {

    if (isset($qv[‘feed’]) && !isset($qv[‘post_type’]))

        $qv[‘post_type’] = array(‘keyword’, ‘slugs’, ‘tags’);

    return $qv;

}

Add Custom Post Types to Your Main WordPress RSS Feed.

Replace the array: keyword, slugs, tags with your posts. Hence, save the changes and activate the code. Head to your RSS feed to notice the changes you made. 

Wrapping up

Lastly, we hope this tutorial was helpful for you and cleared all your doubts regarding custom post types. Furthermore, you can go through our article “How to Limit the Number of Posts in WordPress RSS Feed?” for more information related to this topic. 

LEAVE A REPLY

Please enter your comment!
Please enter your name here