Tutorials WordPress Include Custom Post Types in Your WordPress RSS Feed

Include Custom Post Types in Your WordPress RSS Feed

What are the Feeds?

Feeds are the are the way to distribute your website content beyond readers on Browser. There are thousands of apps such as Feedly, Apple News, Facebook Instant Articles and many more RSS readers applications, that can read your website Feed and present your content to the wider audience.

Readers can also subscribe feeds via their email and get the content delivered directly to their email whenever new posts are published. This allows you to drive traffic to your website and you can also monetize your feeds.

WordPress Built-in Feeds

WordPress supports various conventional feed types such as RDF/RSS 1.0, RSS 2.0 and Atom feed out of the box. You don’t need to write any code to enable for your site.

However, it is enabled by default only for the default post types. If your website is using custom post type, you need to ask WordPress to include the custom post type into RSS feed.

The following code snippet will help you to include WordPress custom post types to your website RSS feed.

Add the following snippets to your WordPress theme functions.php file:

// Add links to rss feed 
function add_to_custom_feed($qv) {
	if (isset($qv['feed']) && !isset($qv['post_type']))
		$qv['post_type'] = array('post', 'books', 'events');
	return $qv;
}
add_filter('request', 'add_to_custom_feed');
Now save the changes in functions.php file and visit your WordPress site RSS feed URL.
For example, my site URL is http://feeds.feedburner.com/stacktips. Notice that now your RSS Feed will now have the posts from custom post types.
Total
0
Shares
guest
0 Comments
Inline Feedbacks
View all comments
Previous Post
Wordpress Tutorials

Show Posts from Specific Categories to Appear on WordPress HomePage

Next Post

Insertion sort example in Java

Related Posts
By clicking “Allow All”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. Cookie Notice
Allow All
0
Would love your thoughts, please comment.x
()
x