# Keep Certain Authors' Posts Out of Feeds

> Leaves posts by the authors you list, such as guest writers or an automated account, out of your main feeds, while their author feed and the posts on the site stay available.

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

## Code

```php
// User IDs or usernames whose posts stay out of the main feeds. Empty = off. Example: array( 7, 'guest-writer' ).
$wpide_feed_hidden_authors = array();

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

    $ids = array();

    foreach ( $wpide_feed_hidden_authors as $author ) {
        $user = is_numeric( $author ) ? get_user_by( 'id', (int) $author ) : get_user_by( 'login', $author );

        if ( $user ) {
            $ids[] = (int) $user->ID;
        }
    }

    if ( $ids ) {
        $query->set( 'author__not_in', array_unique( array_merge( (array) $query->get( 'author__not_in' ), $ids ) ) );
    }
} );
```

## Notes

The author list is empty by default; add user IDs or usernames.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Keep Certain Authors' 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/
