Putting pages into a WordPress RSS feed

Every once in a while I want to put pages into an RSS feed on a self-hosted WordPress site. When I do this, I prefer to have a separate RSS feed for pages.

Here’s the system I use for this. Here’s the RSS for pages code on GitHub.

This is a nice way to add some kinds of client pages to the Pink Sheep Hub, but it’s also a nice way to keep an archive of pages if needed.

add_action( 'pre_get_posts', 't5_pages_in_feed' );

 * Set post type to 'page' if it was requested.
 * @param  object $query
 * @return void
function t5_pages_in_feed( &$query )
    if ( isset ( $_GET['post_type'] ) && $_GET['post_type'] === 'page' && is_feed() )
        $query->set( 'post_type', 'page' );

The feed show up at www.domaindotcom/feed/?post_type=page

Similar Posts