I think I accidentally discovered a bug in ClassicPress (and WordPress) but I’m having difficulty making a replicable test case in a development environment and would appreciate the thoughts of anybody with better familiarity with the relevant code.
Summary: redirect_canonical() mistakes term slugs that look like feed endings (e.g. /tag/rss) and strips them, resulting in unwanted redirection.
Observed on:
- my own ClassicPress 2.7.3 site with
/2026/10/15/sample-post/-style permalinks - a fresh WordPress.com-hosted WordPress site
Not yet found a way to replicate on:
- a fresh development copy of the
developbranch of ClassicPress - a fresh copy of wordpress-develop
Steps to reproduce:
- Create a tag called
rss(orfeed, orrss2, orrdf, oratom). - Create posts with that tag.
Visit /tag/rss- works fine.
Visit /tag/rss/page/2- should show the second page of posts with that tag; instead redirects to/tag/page/2/
Visit /tag/rss/feed- should show the RSS feed of posts with that tag; instead redirects to/tag/feed
I’ve successfully mitigated it in my theme like this:
function q26_no_canonical_for_feedlike_terms( $redirect_url ) {
if ( ! ( is_tag() || is_category() || is_tax() ) ) return $redirect_url;
$term = get_queried_object();
if ( isset( $term->slug ) && preg_match( '/^(feed|rss2?|rdf|atom)$/', $term->slug ) ) return false;
return $redirect_url;
}
add_filter( 'redirect_canonical', 'q26_no_canonical_for_feedlike_terms' );
But I feel like there must be a core issue here. I’ll continue trying to replicate it on a development system, but if anybody’s got any bright ideas I’d love to hear them!