Add a new feed type like /atom1/.
Requires one-time use of flush_rules() to take effect.
<?php add_feed( $feedname, $function ); ?>
Use the init action to call this function.
<?php
/* Add the feed. */
function my_custom_rss_init(){
add_feed('my_custom_feed', 'my_custom_rss');
}
add_action('init', 'my_custom_rss_init');
/* Filter the type, this hook wil set the correct HTTP header for Content-type. */
function my_custom_rss_content_type( $content_type, $type ) {
if ( 'my_custom_feed' === $type ) {
return feed_content_type( 'rss2' );
}
return $content_type;
}
add_filter( 'feed_content_type', 'my_custom_rss_content_type', 10, 2 );
/* Show the RSS Feed on domain.com/?feed=my_custom_feed or domain.com/feed/my_custom_feed. */
function my_custom_rss() {
// Do your magic, with XML for example.
}
?>
Since: 2.1
add_feed() is located in wp-includes/rewrite.php