Combine WordPress post types into a single RSS feed

Out of the box WordPress will create a unique RSS feed per post type as well as taxonomies like categories and tags.

I take advantage of this by offering readers several feed options on the Subscribe page. Only want to subscribe to notes? No problem, follow the RSS feed for the notes post type. The same goes for links and posts.

But what about a feed that includes all content? Well, that’s not quite as straightforward with WordPress. Immediately, you’d think that the main feed would include all content types. It doesn’t. Instead, it only includes posts.

Having subscribed to 100+ blogs over the past month, I’m fine with that. When I subscribe to the default RSS feed, my expectation is that it will only include posts. If you post notes and snapshots and checkins, that’s cool. But that’s not something I want in my RSS reader. And, if I did, I would seek out an “all content” feed.

Still, I think everyone should offer an “all content” feed. Myself included.

There are several ways to achieve this, but all of them are kinda complicated. The easiest way is to modify the “functions.php” file of your theme with a code snippet that registers the new feed. If you’re going down this route, you should make sure that you have a child theme where you apply the modifications. Otherwise your changes will be overwritten the next time you update your feed.

Since I’m running a bog standard install of Twenty Twenty-Four, I couldn’t be bothered to set up a child theme. Instead, I went for the other option: Creating a super simple plugin that does the job. It’s so simple that even I could put it together.

<?php
/*
Plugin Name: Custom Combined Feed
Plugin URI:  https://lars-christian.com/
Description: This plugin adds a custom RSS feed that combines the post types "post", "note" and "link".
Version:     0.01
Author:      Lars-Christian Simonsen
Author URI:  https://lars-christian.com
*/

function custom_add_feed() {
    add_feed('allcontent', 'custom_feed_callback');
}

add_action('init', 'custom_add_feed');

function custom_feed_callback() {
    load_template(ABSPATH . WPINC . '/feed-rss2.php');
}

function custom_query_for_combined_feed($query) {
    if ($query->is_feed('allcontent')) {
        $query->set('post_type', ['post', 'note', 'link']);
    }
}

function custom_feed_title($title) {
    if (is_feed('allcontent')) {
        return get_option('blogname') . ' – All content';
    }

    return $title;
}

add_filter('wp_title_rss', 'custom_feed_title', 10, 1);

add_action('pre_get_posts', 'custom_query_for_combined_feed');

What this little plugin does is registering the custom feed, in this case called “allcontent” and loading the default RSS 2.0 template for this new feed. Afterwards, it creates the query for the new feed. Here, you can see that the desired post types are included, in this case “post”, “note” and “link”. And, lastly, we set the name for the feed.

And that’s it!

Once the plugin is activated, the new custom feed will be available at wordpress.url/feed/allcontent – or whatever you decided to call your new feed.

Easy peasy. Feel free to use the plugin if you have similar needs. Simply copy the code into a .php file, make the necessary adjustments and upload it to your /plugins/ folder before activating it.

Thanks to bacardi55 (he also has a cool blog) who pointed out that the post only RSS feed previously wasn’t working as intended. I wouldn’t have put this fix in place if he hadn’t let me know.