# Keep Password-Protected Posts Out of Feeds

> Removes password-protected posts from all feeds, where they otherwise appear with a "There is no excerpt because this is a protected post" message.

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

## Code

```php
add_action( 'pre_get_posts', function ( $query ) {
    if ( ! is_admin() && $query->is_main_query() && $query->is_feed() ) {
        $query->set( 'has_password', false );
    }
} );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Keep Password-Protected Posts Out of 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/
