How to Exclude Posts from Your WordPress RSS Feed

WordPressRSSTutorials
5 min read
================================================================================
C:\ARCHIVE\2008> DIR /W
Volume in drive C is NOSTALGIA
Volume Serial Number is 2008-0724
README.TXT:
Originally posted: 2008 (17 years ago)
Status: REWRITTEN FOR 2025
Note: Original post lost; this is a modern recreation
Nostalgia level: 17KB loaded successfully
================================================================================
C:\ARCHIVE\2008> TYPE CONTENT.MD_

How to Exclude Posts from Your WordPress RSS Feed

Whether you're publishing sponsored content, internal updates, or posts that don't fit your main feed's purpose, there are many reasons to exclude certain posts from your WordPress RSS feed. This guide covers multiple methods, from simple to advanced, for controlling what appears in your feed.

Quick Solutions

Method 1: Using Categories (Simplest)

The easiest way to exclude posts is by using a dedicated category and filtering it out.

Step 1: Create an "Exclude from Feed" category (or similar name)

Step 2: Add this code to your theme's functions.php file:

function exclude_category_from_feed($query) {
    if ($query->is_feed()) {
        // Replace 5 with your category ID
        $query->set('cat', '-5');
    }
    return $query;
}
add_filter('pre_get_posts', 'exclude_category_from_feed');

To find your category ID: Go to Posts → Categories, hover over the category name, and look at the URL. The number after category&tag_ID= is your category ID.

Method 2: Using Custom Fields

For more granular control, use a custom field to mark posts for exclusion.

Step 1: Add a custom field called exclude_from_feed to posts you want to hide

Step 2: Add this code to functions.php:

function exclude_posts_with_custom_field($query) {
    if ($query->is_feed()) {
        $query->set('meta_query', array(
            array(
                'key' => 'exclude_from_feed',
                'compare' => 'NOT EXISTS'
            )
        ));
    }
    return $query;
}
add_filter('pre_get_posts', 'exclude_posts_with_custom_field');

Advanced Methods

Method 3: Exclude Multiple Categories

To exclude multiple categories from your feed:

function exclude_multiple_categories_from_feed($query) {
    if ($query->is_feed()) {
        // Exclude categories 5, 12, and 18
        $query->set('cat', '-5,-12,-18');
    }
    return $query;
}
add_filter('pre_get_posts', 'exclude_multiple_categories_from_feed');

Method 4: Exclude by Post Format

If your theme supports post formats, you can exclude specific formats:

function exclude_post_formats_from_feed($query) {
    if ($query->is_feed()) {
        $query->set('tax_query', array(
            array(
                'taxonomy' => 'post_format',
                'field' => 'slug',
                'terms' => array('post-format-aside', 'post-format-status'),
                'operator' => 'NOT IN'
            )
        ));
    }
    return $query;
}
add_filter('pre_get_posts', 'exclude_post_formats_from_feed');

Method 5: Exclude Specific Post IDs

For excluding individual posts by ID:

function exclude_specific_posts_from_feed($query) {
    if ($query->is_feed()) {
        // Exclude posts with IDs 123, 456, and 789
        $excluded_posts = array(123, 456, 789);
        $query->set('post__not_in', $excluded_posts);
    }
    return $query;
}
add_filter('pre_get_posts', 'exclude_specific_posts_from_feed');

Plugin Solutions

If you prefer not to edit code, these plugins can help:

Free Plugins

Ultimate Category Excluder - Simple interface for excluding categories from feeds, homepage, and archives.

Advanced Feed Control - Provides granular control over RSS feeds with a user-friendly interface.

Premium Solutions

Many SEO plugins like Yoast SEO and Rank Math include RSS feed control features in their premium versions, allowing you to exclude posts without coding.

Creating Custom Feeds

Sometimes it's better to create additional feeds rather than excluding content from the main feed.

Create a Category-Specific Feed

WordPress automatically creates feeds for categories. Access them at:

  • yoursite.com/category/category-name/feed/

Create a Custom Feed

Add this to functions.php to create a completely custom feed:

function create_custom_feed() {
    add_feed('custom', 'render_custom_feed');
}
add_action('init', 'create_custom_feed');

function render_custom_feed() {
    header('Content-Type: application/rss+xml; charset=UTF-8');
    
    $args = array(
        'posts_per_page' => 10,
        'cat' => '3,7,9', // Include only these categories
        'post_status' => 'publish'
    );
    
    $custom_query = new WP_Query($args);
    
    // Output RSS XML
    echo '<?xml version="1.0" encoding="UTF-8"?>';
    ?>
    <rss version="2.0">
        <channel>
            <title><?php bloginfo_rss('name'); ?> - Custom Feed</title>
            <link><?php bloginfo_rss('url'); ?></link>
            <description><?php bloginfo_rss('description'); ?></description>
            <?php while($custom_query->have_posts()) : $custom_query->the_post(); ?>
            <item>
                <title><?php the_title_rss(); ?></title>
                <link><?php the_permalink_rss(); ?></link>
                <description><?php the_excerpt_rss(); ?></description>
                <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
            </item>
            <?php endwhile; ?>
        </channel>
    </rss>
    <?php
}

After adding this code, flush your permalinks (Settings → Permalinks → Save Changes) and access your custom feed at yoursite.com/feed/custom/.

Troubleshooting

Changes Not Showing?

RSS feeds are heavily cached. After making changes:

  1. Clear WordPress cache if you're using a caching plugin
  2. Wait for feed readers to update (can take 1-24 hours)
  3. Test with a feed validator like W3C Feed Validator
  4. Add a query parameter to force refresh: yoursite.com/feed/?nocache=1

Feed Not Working After Code Changes?

  • Check for PHP syntax errors in your functions.php
  • Ensure you're using the correct hook (pre_get_posts for queries)
  • Verify category/post IDs are correct
  • Test with WordPress debugging enabled

Exclude from Feed but Keep on Homepage?

Modify the conditional to be more specific:

function exclude_only_from_feed($query) {
    if ($query->is_feed() && !$query->is_home()) {
        $query->set('cat', '-5');
    }
    return $query;
}
add_filter('pre_get_posts', 'exclude_only_from_feed');

Best Practices

Use Child Themes: Always add custom code to a child theme's functions.php to preserve changes during theme updates.

Document Your Exclusions: Keep a record of why certain posts or categories are excluded for future reference.

Consider Feed Readers: Remember that some readers cache aggressively. Changes might not appear immediately for all subscribers.

Test Thoroughly: Use feed validators and multiple feed readers to ensure your exclusions work as expected.

Plan Your Content Structure: Design your category and tagging system with feed management in mind from the start.

Performance Considerations

Excluding posts from feeds adds database queries. For high-traffic sites:

  • Use object caching (Redis/Memcached)
  • Consider creating static feeds with a plugin like WP Super Cache
  • Limit the number of exclusion rules
  • Use category exclusion over custom field exclusion when possible (more efficient)

Conclusion

Controlling what appears in your WordPress RSS feed gives you flexibility in content distribution. Whether you choose the simple category method or create custom feeds, test your implementation thoroughly and remember that feed readers may take time to reflect changes.

For sites with complex requirements, combining multiple methods or using a dedicated plugin might be the best approach. The key is choosing a solution that fits your workflow and technical comfort level.