make separate rss feed for each custom post type og 1

Do you want to create a distinct RSS feed for each of your WordPress website’s custom post types?

Website owners can use custom post types to create their own unique content types. These post types may include functionality comparable to posts or pages, such as an RSS feed.

 

Making RSS feed for custom post types in WordPress

Using WordPress to Create Separate RSS Feeds for Custom Post Types
WordPress creates many RSS feeds for your website by default.

For example, your primary RSS feed includes all of your most current blog posts. By adding /feed/ to your domain name, you can access this feed:

https://example.com/feed/

Most newcomers are unaware that WordPress creates distinct RSS feeds for each of their website’s archive pages.
It offers RSS feeds for categories, tags, authors, and custom post kinds, for example.

Let’s imagine your website has a custom post type named movies. By visiting the post type archive page, you may see all of the content generated in that post type.

https://example.com/movies

Example of a custom post type archive page

To read the RSS feed, simply append /feed/ to the end of the custom post type archive URL.

https://example.com/movies/feed/

Custom post type RSS feed in WordPress

You can also access the feed by including the post type option in your regular WordPress RSS feed. Consider the following scenario:

https://example.com/feed/?post type=movies

This URL will only provide results for the movies custom post type.

Alternate custom post type RSS feed URL

Add a link to the RSS Feed for Custom Post Types

You may use that URL to generate links to your custom post type feeds now that you know how to access the RSS feeds for any custom post type on your website.

 

For example, on the custom post type archive page, you could wish to include an icon or a plain text link so that visitors can quickly subscribe to those posts.

 

The simplest approach to achieve this is to create a separate template in your WordPress theme for your custom post type.

 

Create an archive-post type.php file in your WordPress theme if your custom post type is called movies, for example.

After that, you can start customizing your new template by copying the data from your theme’s existing archive.php template.

Using the following code, you can easily add a plain HTML link to your post type archive feed:

1
<p><strong>Subscribe to: <a href="https://example.com/movies/feed/">Movies</a></strong></p>

Remember to replace the URL with your own post type feed URL.

The issue with this code is that you’ll have to develop a new template file specifically for that post type.

The next approach allows you to construct the post type RSS feed link for all of your archive pages dynamically.

Simply paste the following code into the archive.php template file of your theme.

1
2
3
4
<?php if ( is_post_type_archive() ) {
$post_type = get_post_type( get_queried_object_id() );?>
                <p><strong>Subscribe to: <a href="<?php echo get_post_type_archive_link( $post_type  ); ?>feed/"><?php post_type_archive_title(); ?></a></strong></p>
<?php } ?>       

This code will simply add a link to the archive page title of the post type, urging people to subscribe to that content kind.

post type feed link

We hope this article demonstrated how to build a distinct RSS feed in WordPress for custom post kinds. You might also be interested in our WordPress guide on how to create an email subscription form or our WordPress RSS feed optimization recommendations.

 

Leave a Reply