Yearly Archive is Broken When Custom Permalink Contains Page Slug
|Reported by:||fonetik||Owned by:||anonymous|
|Severity:||normal||Keywords:||rewrite, permalink, canonical, url|
If the index of a Wordpress blog is configured to show a page and the blog loop then runs when another page is accessed, then it is natural to have that page slug as the first entry in the permalink path.
In my specific case, "/" shows the "Main" page, so I created a "Blog" page (whose slug is "blog") on which the normal blog posts loop runs. I have custom permalinks which look like "/blog/year/month/day/post-slug".
Single entries, daily archives, and monthly archives can all be accessed correctly, but yearly archives just show the blog front page (as if the URL path was "/blog/" instead of "/blog/2006/".
The same issue results if the first directory in the permalink path is the same as a normal page slug, though in that case the yearly archive URL just shows that page.
I spent a lot of time looking through rewrite.php and it seems that the issue could have something to do with the relaxed pagination rules which allow "/blog/2/" to reference the second page of paginated posts instead of the canonical "/blog/page/2/" although it could also be a problem with the URL being matched by the relaxed attachments rules which allow "/page/attachment-name/" instead of the "/page/attachment/attachment-name/".
More generally, it seems that there are a lot of overly general URLs accepted by the rewrite. The new canonical URL stuff in 2.3 is great, but it seems strange that there is code to reduce the number of URLs in canonical.php when there is extra code in rewrite.php that only exists to create multiple URLs which point to the same thing (pagination, attachments, and feeds seem to be the worst offenders).