Skip to main content
added 92 characters in body
Source Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459

Feeds for post types are called with feed/?post_type=POSTTYPE. For no obvious reasons this doesn't work for the post type page – you get the posts instead.

But there is a filter to fix that: 'pre_get_posts'. Let's use it:

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' );
    }
}

Now you get the page feed at /feed/?post_type=page.

Here is a plugin for that: T5 Page Feed

Feeds for post types are called with feed/?post_type=POSTTYPE. For no obvious reasons this doesn't work for the post type page – you get the posts instead.

But there is a filter to fix that: 'pre_get_posts'. Let's use it:

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' );
    }
}

Now you get the page feed at /feed/?post_type=page.

Feeds for post types are called with feed/?post_type=POSTTYPE. For no obvious reasons this doesn't work for the post type page – you get the posts instead.

But there is a filter to fix that: 'pre_get_posts'. Let's use it:

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' );
    }
}

Now you get the page feed at /feed/?post_type=page.

Here is a plugin for that: T5 Page Feed

Source Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459

Feeds for post types are called with feed/?post_type=POSTTYPE. For no obvious reasons this doesn't work for the post type page – you get the posts instead.

But there is a filter to fix that: 'pre_get_posts'. Let's use it:

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' );
    }
}

Now you get the page feed at /feed/?post_type=page.