Custom Post Type Feed Without Content in Box
Do you want to make a separate RSS feed for each custom post type on your WordPress website?
Custom post types allow website owners to add their own unique content types. These post types can have similar features to posts or pages, including an RSS feed.
In this article, we'll show you how to easily make a separate RSS feed for custom post types in WordPress.
Creating Separate RSS Feeds for Custom Post Types in WordPress
By default, WordPress generates several RSS feeds for your website.
For instance, all your recent blog posts appear in your site's main RSS feed. This feed can be accessed by adding /feed/ to your domain name:
https://example.com/feed/
What most beginners don't know is that WordPress generates separate RSS feeds for different archive pages of their website.
For instance, it has separate RSS feeds for categories, tags, authors, and custom post types.
Let's say you have a custom post type called movies on your website. You can view all content created in that post type by visiting the post type archive page.
https://example.com/movies
To view the RSS feed, all you need to do is add /feed/ next to the custom post type archive URL.
https://example.com/movies/feed/
Alternately, you can also view the feed by adding the post type parameter to your main WordPress RSS feed. For example:
https://example.com/feed/?post_type=movies
This URL will then only fetch the custom post type called movies.
Add a Link to Custom Post Type RSS Feed
Now that you know how to access the RSS feeds for any custom post type on your website, you can use that URL to create links to your custom post type feeds.
For instance, you may want to display an icon or a plain text link on the custom post type archive page, so that your visitors can easily subscribe to those posts.
The easiest way to do this is by creating a separate template for your custom post type in your WordPress theme.
For instance, if your custom post type is called movies then you can create an archive-{post_type}.php file in your WordPress theme.
After that, you can simply copy the contents from your theme's existing archive.php template and start customizing your new template.
You can simply add a plain HTML link to your post type archive feed using the following code:
<p><strong>Subscribe to: <a href="https://example.com/movies/feed/">Movies</a></strong></p>
Don't forget to change the URL to your own post type feed URL.
Now, the problem with this code is that you'll have to create a new template file just for that particular post type.
This next method will allow you to dynamically generate the post type RSS feed link for all your archive pages.
Simply add the following code to your theme's archive.php template file.
<?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 below the post type's archive page title, encouraging users to subscribe to this particular content type.
We hope this article helped you learn how to create a separate RSS feed for custom post types in WordPress. You may also want to see our tutorial on how to add an email subscription form in WordPress or check out our tips on optimizing your WordPress RSS feeds.
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.
Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.
Source: https://www.wpbeginner.com/wp-tutorials/how-to-make-a-separate-rss-feed-for-each-custom-post-type-in-wordpress/
0 Response to "Custom Post Type Feed Without Content in Box"
Post a Comment