By doing a simple:
add_feed( 'schedule', 'my_schedule_feed' );
I have created a feed at /feed/schedule/
... easy.
But when I go to /schedule/
(which is a page) it is now showing the feed!
Looking at the rewrite rules I see this:
[feed/(feed|rdf|rss|rss2|atom|schedule)/?$] => index.php?&feed=$matches[1]
[(feed|rdf|rss|rss2|atom|schedule)/?$] => index.php?&feed=$matches[1]
This seems really odd. Why would WordPress overwrite existing page rules with the feed, instead of just using only the /feed/
base as expected?
Update: I have tried this as suggested by this answer, and flushing the permalinks, but while it shows up in the rewrites, it does not show the feed at /feed/schedule/
function add_feed_rewrites( $wp_rewrite ) {
$feednames = array( 'schedule', 'calendar' );
$feeds = implode( '|', $feednames);
$feed_rule = array(
'feed/(' . $feeds . ')/?$' => 'index.php?&feed=$matches[1]'
);
$wp_rewrite->rules = array_merge( $wp_rewrite->rules, $feed_rule );
}
add_filter( 'generate_rewrite_rules', 'add_feed_rewrites' );
add_action( 'do_feed_schedule', 'my_schedule', 10, 2 );
add_action( 'do_feed_calendar', 'my_calendar', 10, 2 );
Any ideas on how to get this working without the initial conflict?