If you are running your WordPress site as a CMS, you may come across need to include pages from your site in the main feed, along with your posts. Well, the below code will give you that ability.
function add_pages_to_rss_feed( $args ) { if ( isset( $args['feed'] ) && !isset( $args['post_type'] ) ) $args['post_type'] = array('post', 'page'); return $args; } add_filter( 'request', 'add_pages_to_rss_feed' );
All it is doing is to include the post type ‘Page’ in the feed.
I have created a plugin that does the above. If you don’t want to manually edit any code, install Pages and Posts in Feed plugin.
So, if you’d like to include additional custom post types in feed, you can do that by including them in the arguments array like this:
$args['post_type'] = array('post', 'page', 'movies', 'songs');
And finally, if you don’t want any blog posts to show up in the feed, simply remove post type ‘Post’ from the argument. That would look something like this:
$args['post_type'] = array('page', 'movies', 'songs');
With this code in your default theme’s functions.php
file, all “Post” items would be excluded from the feed.
Similar to earlier plugin, if you want only pages in your feed, get Only Pages in Feed plugin.
With the code in place, the number of items in feed is still controlled from ‘Reading Settings’ in WordPress dashboard.
4 thoughts on “Add Pages, Custom Post Types in WordPress Site Feed”
Thanks for the info..!!!
Hi: Renji:
I am interest to allow the feed to point to certain page to publish their updated items from recent ly updated pages (no post). Will your Add Pages, Custom Post Types in WordPress Site Feed
Plugin do this or addition programming is involve? If not, can your include this in next version. I wish to have a pick list to enable certain page feeds on a page (Home page).
Thanks
David