# Add Custom Post Types to the RSS Feed

> Includes entries from custom post types in the main RSS feed along with regular posts.

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

## Code

```php
add_filter( 'request', function ( $query_vars ) {
    if ( isset( $query_vars['feed'] ) && ! isset( $query_vars['post_type'] ) && ! isset( $query_vars['withcomments'] ) ) {
        $query_vars['post_type'] = array( 'post', 'portfolio' );
    }

    return $query_vars;
} );
```

## Notes

Replace portfolio with your post type names.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Add Custom Post Types to the RSS Feed" 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/
