How to Show Custom Post Type in RSS Feed

Recently, a client asked me how to show custom post type in RSS feed since WordPress only includes ‘Posts’ by default. I did a quick search and found the fine folks from WPBeginner had offered a solution here. Below is their code snippet and how to use it for your own purposes:


Method 1: Adds everything into main feed

This snippet would add every custom post type to the main feed. Unfortunately, that may not be exactly what you want.

function myfeed_request($qv) {
	if (isset($qv['feed']))
		$qv['post_type'] = get_post_types();
	return $qv;
add_filter('request', 'myfeed_request');

Method 2: Add specific custom post types to RSS feed

The snippet below provides an array to specifically identify which RSS feeds you want to display in the main rss feed. For example, the snippet below would show the regular posts, as well as the custom post type posts of story, 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');

How to Use This Code?

Since providing just this snippet may not be straight-forward for non-programmers, let’s walk through the process in steps:

1) open your functions.php file. You can navigate to this file from your WordPress backend: Appearance > Editor > and then on the right side, click on functions.php

2) Paste the code snippet you prefer to the bottom of the functions.php file. If you choose method 2, be sure to identify your own custom post types. If you do not know the exact name of your custom post type, simply hover over its tab inside WordPress back-end, and check the URL permalink. Within the URL, you will find this text string: ?post_type=_______. The name at the end of that string is the name of your custom post type which you should enter into the code snippet.

3) Save your file. If you experience any issues thereafter, then try wrapping the code above in php template tags. All that means is to place the following at top of the code snippet <?php and this ?> at the end of the snippet.

Let me know if this code works for you in the comments. will feature articles on WordPress (themes, plugins, and tutorials, Internet Marketing, Blogging, SEO, Web Design, and Social Media

Leave a Reply

Your email address will not be published. Required fields are marked *