• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

virusword.com-Wordpress

Learn Wordpress

  • Home
  • WordPress Shop
    • Fotopress
    • SEO Tool Kit
    • Social Contact
    • Tag Machine 2
    • Video Profits
  • Latest News
  • WordPress
    • Plugins
    • Themes
    • Tutorials
    • Videos
    • Woocommerce
  • About Us
  • Contact Us
    • Terms of Service
    • Privacy Policy
  • Show Search
Hide Search
Home/Tutorials/How to Add Custom Post Types to Your Main WordPress RSS Feed

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

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

By default, the WordPress RSS feed only shows your recent blog posts. However, if you are using custom post types for other content, then you may want to include them in your main RSS feed as well.

In this article, we’ll show you how to easily add custom post types to your main WordPress RSS feed.

Easily add custom post types to main WordPress RSS Feed

Why Add Custom Post Types to Main RSS Feed in WordPress?

By default, WordPress comes with two commonly used content types called posts and pages. However, you can also create custom post types to add more content types if needed.

For instance, a movie review website may want to create a custom post type for movie reviews using custom taxonomies suitable for that particular content type.

A custom post type in WordPress

Now, your custom post types can have their own RSS feed which users can access by adding /feed/ at the end of the custom post type archive URL.

https://example.com/custom-post-type/feed/
https://example.com/movies/feed/

However, the custom post-type feeds are not easily discoverable. If a user enters your website’s URL in their feed reader, then it will show the subscription option for your main WordPress RSS feed.

Feed reader showing main RSS feed at the top

That being said, let’s see how to easily fix that by adding custom post type to your main WordPress RSS feed.

Adding All Custom Post Types to Your WordPress RSS Feed

This method allows you to add all publicly available post types to be included in your main WordPress RSS feed.

You’ll need to add code to your WordPress website. If you haven’t done this before then take a look at our guide on how to easily add custom code snippets in WordPress.

Simply copy and paste the following code to your theme’s functions.php file or a site-specific plugin.

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

This code simply modifies the default WordPress query to fetch RSS feeds by adding all publicly visible post types into the query.

This will allow you to add pages as well as all other custom post types into your main WordPress RSS feed.

Adding Specific Custom Post Types in Main WordPress RSS Feed

This method is more flexible and allows you to choose which post types you want to include into your main WordPress RSS feed.

Simply copy and paste the following code into your WordPress website.

function myfeed_request($qv) {
    if (isset($qv['feed']) && !isset($qv['post_type']))
        $qv['post_type'] = array('post', 'movies', 'books');
    return $qv;
}
add_filter('request', 'myfeed_request');

You can now visit your WordPress RSS feed to see this code in action.

We hope this article helped you add custom post types to your main WordPress RSS feed. You may also want to see our tips to optimize WordPress RSS feeds or see these best WordPress RSS feed plugins for bloggers.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Source link

Written by:
Abdul Wahid
Published on:
December 22, 2021

Categories: Tutorials

Primary Sidebar

Wordpress

  • Latest News (270)
  • Plugins (308)
  • Themes (312)
  • Tutorials (393)
  • Videos (801)
  • Woocommerce (400)

Recent Articles

Best WordPress Themes for Affiliate Marketing | User-friendly, Fast, SEO & CTR Optimized

In this video from the full playlist on affiliate …

Continue Reading about Best WordPress Themes for Affiliate Marketing | User-friendly, Fast, SEO & CTR Optimized

How to Enable Automatic Updates in WordPress for Major Versions

Do you want to enable automatic updates for major …

Continue Reading about How to Enable Automatic Updates in WordPress for Major Versions

Search our site

Explore more

Get our Wordpress Guide Get Plugins Get Connected

Footer

VirusWord by Promaps, Inc.

Barnes Place
Colombo 7, Western 00700

Copyright © 2023 · Promaps, Inc.

Keep In Touch

  • Email
  • Facebook
  • Instagram
  • Pinterest
  • Twitter