# Keep Tagged Posts Out of RSS Feeds

> Leaves any post with a "no-feed" tag out of all RSS feeds, so you can publish a post on the site without sending it to subscribers and newsletter tools.

- Type: PHP
- Runs: Run everywhere
- Category: [RSS Feeds](https://wpide.com/library/category/rss/)
- Tags: rss, tags, exclude
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/exclude-tagged-posts-from-feeds/

## Code

```php
// Tag slug that keeps a post out of feeds.
$wpide_no_feed_tag = 'no-feed';

add_action( 'pre_get_posts', function ( $query ) use ( $wpide_no_feed_tag ) {
    if ( is_admin() || ! $query->is_main_query() || ! $query->is_feed() || $query->is_comment_feed() ) {
        return;
    }

    $tag = get_term_by( 'slug', $wpide_no_feed_tag, 'post_tag' );

    if ( $tag ) {
        $query->set( 'tag__not_in', array_merge( (array) $query->get( 'tag__not_in' ), array( (int) $tag->term_id ) ) );
    }
} );
```

## Notes

Create a tag with the slug no-feed (or change the slug at the top) and add it to posts you want to hide from feeds.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Keep Tagged Posts Out of RSS Feeds" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
