Reputation: 1697
I'm trying to load different RSS feeds in WordPress in a custom PHP file. I can get the RSS feed template to load using the following:
do_feed();
This loads the RSS feed fine but it contains no posts. It seems that the Posts loop isn't setup.
Does anyone know how to I would go about getting different RSS feeds in this way? I will need the standard homepage RSS feed as well as comments feeds and category/tag RSS feeds.
Upvotes: 0
Views: 628
Reputation: 6828
do_feed()
needs $wp_query
and a feed
query var to be set. So I guess you could do a custom query and set the feed var:
if( empty( $doing_rss ) ) {
$doing_rss = 1;
require(ABSPATH . '/wp-blog-header.php');
}
$query = new WP_Query( array( 'post_type' => 'post' ) );
global $wp_query;
$wp_query = $query;
$wp_query->query_vars['feed'] == 'rss2';
do_feed();
Upvotes: 2