How to show page content in feed?

First set the post type to display on main feed page i.e. /feed using pre_get_posts hook

$q->set('post_type', array('post', 'page'));

On individual page WordPress shows comment feed then set it to false and display page content in feed.

$q->is_comment_feed = false;

In feed template WordPress calls the_excerpt_rss() which calls get_the_excerpt() so using excerpt_length filter change the length to max.

Complete Example:-

add_action('pre_get_posts', 'wpse_227136_feed_content');
/**
 * Set post type in feed content and remove comment feed
 * @param type $q WP Query
 */
function wpse_227136_feed_content($q) {
    //Check if it main query and for feed
    if ($q->is_main_query() && $q->is_feed()) {
        //Set the post types which you want default is post
        $q->set('post_type', array('post', 'page'));
    }

    //Check if it feed request and for single page 
    if ($q->is_main_query() && $q->is_feed() && $q->is_page()) {
        //Set the comment feed to false
        $q->is_comment_feed = false;
    }
}

add_filter( 'excerpt_length', 'wpse_227136_excerpt_length', 999 );
/**
 * Filter the except length to full content.
 *
 * @param int $length Excerpt length.
 * @return int $length modified excerpt length.
 */
function wpse_227136_excerpt_length( $length ) {
    if (is_feed() && !get_option('rss_use_excerpt')) {
        return PHP_INT_MAX;
    }

    return $length;
}

Leave a Comment