I'm attempting to add a rewrite so feeds for pages that list specific post categories work.
eg. /mining-civil-engineering/newsroom/feed/
would point to index.php?cat=21,22&feed=rss2
These rewrites are added programatically based on a template type, so they don't have to be added manually. I'm using add_rewrite_rule
.
Unfortunately, $wp_rewrite
still seems to only match to the rule designating page comments (.?.+?)/(feed|rdf|rss|rss2|atom)/?$
outputting to pagename=mining-civil-engineering%2Fnews-events&feed=feed
.
I tried using $wp_rewrite->non_wp_rules
so my .htaccess now looks like
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^national-security/events/feed/ /index.php?cat=10&feed=rss2 [QSA,L]
RewriteRule ^mining-civil-engineering/news-events/feed/ /index.php?cat=21,22&feed=rss2 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Unfortunately it still seems to only match on the previous query. I commented out in my htaccess lines until it knew it was only working with the rewrite I wanted, but the body still returned the comments feed, and my debugging showing it was matching on the feed url. I did flush with both $wp_rewrite->flush_rules( true );
and re-saving permalinks in the admin.
Any ideas on what I'm doing wrong? I'm utterly lost.
Thanks!!
.htaccess
(to override WordPress's default behaviour) is often problematic because WordPress still sees the original URL on the request (ie./national-security/events/feed/
- the value of$_SERVER['REQUEST_URI']
) and routes the request according to that. (?)