18 September 2013

Wordpress custom rss feed


I needed to create a custom rss feed so that some of my wordpress data could be syndicated.


  1. Make a copy of wp-includes/feed-rss2 into a /feeds directory for your theme
  2. Edit the file name to replace rss2 in filename and edit the xml as necessary
  3. Copy the following into functions.php

function do_feed_($for_comments) {
load_template(STYLESHEETPATH . '/feeds/feed-.php');
}
add_action('do_feed_', 'do_feed_', 10, 1);

and then load using http://yourblog.com/?feeds=

Behind the scenes wordpress takes the feeds parameter and looks for the function do_feed_, which you have now set to turn to your feed template

Easy!

No comments: