Cannot get add_feed to work

Code is working :

add_feed('myfeed_rss2', 'my_feed');

function my_feed() {
add_filter('pre_option_rss_use_excerpt', '__return_zero');
load_template( TEMPLATEPATH . '/custom-feed.php' );
}

RSS is contextual : if I add ?feed=myfeed_rss2 after index url, this will tell WP to display the content of the home with the template custom-feed.php – it’s more a filter than anything else. I was considering RSS from a wrong point of view.

If I add ?feed=myfeed_rss2after a category page url, it will display the category page with the template custom-feed.php.

I didn’t find a way still to alter the query from the template, this should be done differently, i.e. creating a special page in theme and then calling the RSS template upon it (for example, having a RSS feed 50 article long).

The RSS template is only the strict XML structuration of the content, with the ability to use PHP code to add information (like file length in bytes for enclosures).

ADDITIONALLY

Something reaaally important if people try to use / manage custom feed : feed only are created / modified upon post modification / addition. To put it straight, you have to publish a new post (or put some old one as draft, do some test, then re-publish it, do some test…) to check any change made into the RSS template.

Leave a Comment