Opened 11 years ago
Last modified 3 weeks ago
#28156 reopened defect (bug)
In date-containing permalink structures, /dddd/dd/comment-page-d/ urls don't work
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9 |
Component: | Permalinks | Keywords: | needs-patch dev-feedback needs-unit-tests |
Focuses: | Cc: |
Description
I was in the process of writing a plugin to allow people to test their rewrite rules as they develop a site, and when I setup examples of core rewrite rules, one of them was failing.
If you set your permalink structure to one containing dates, e.g. "Day and Name", one of the generated rewrite rules for posts is:
'([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]'
And later on, another rule is:
'([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&cpage=$matches[4]'
The URI /2014/5/6/comment-page-2/ would end up matching the earlier rule, looking for a post named "comment-page-2" published on 2014-05-06, instead of looking for comment page 2 in the... I actually don't even know what the comment-page URLs do. For me, the ones that work just redirect to the date archive.
I'm happy to patch this, but would like to hear from someone else on what exactly should be done done. Do the comment-page-n rules do anything? Can they just be removed?
Attachments (2)
Change History (8)
#2
@
10 years ago
- Keywords needs-unit-tests added; needs-testing removed
I wasn't aware that you could view comments outside of their posts in an date based archive format.
#3
@
4 weeks ago
- Resolution set to invalid
- Status changed from new to closed
Hi All,
I have taken a look at this in the latest release, and it looks like the comments page rewrite rules no longer exist within WordPress. As of such I don't believe this is an issue in the current state of the codebase.
#4
@
4 weeks ago
- Resolution invalid deleted
- Status changed from closed to reopened
@callumbw95 I just checked on 6.8.1 and the comment page rules do still exist and the issue also persists as originally described. Perhaps you didn't follow the step, If you set your permalink structure to one containing dates, e.g. "Day and Name"
?
#5
@
3 weeks ago
Hey @mboynes,
Yes you are correct, my mistake there, I think I jumped the gun there a bit, as I can see the rewrite rule in the code now too. I have set up a fresh test site with the correct Day and Name permalink structure, and I have created a test post with multiple comments that go across multiple pages. However I am not seeing the issues you are having here with url's not working?
I have the following url's and they are working as intended:
- /2025/06/26/28156-test-page/comment-page-1/#comments
- /2025/06/26/28156-test-page/comment-page-2/#comments
- /2025/06/26/28156-test-page/comment-page-3/#comments
Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.4.7
- Server: nginx/1.27.5
- Database: mysqli (Server: 8.0.40 / Client: mysqlnd 8.4.7)
- Browser: Chrome 137.0.0.0
- OS: macOS
- Theme: Twenty Twenty Five 1.2
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
#6
@
3 weeks ago
Hey @callumbw95, the ticket is a bit confusing. I'd make it more clear, but I don't actually understand the intended functionality. The URLs that don't work aren't single-post comment page urls (as you were looking at), they're (I guess?) date archive comment page URLs. An example URL is /2025/06/26/comment-page-2/
.
The specific rule is:
([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$ => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&cpage=$matches[4]
There are other, similar rules, that don't 404 but don't seem to show anything comments-related:
([0-9]{4})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$ => index.php?year=$matches[1]&monthnum=$matches[2]&cpage=$matches[3] ([0-9]{4})/comment-page-([0-9]{1,})/?$ => index.php?year=$matches[1]&cpage=$matches[2]
My best guess is that the real bug here is that these urls are invalid and are added inadvertently, probably here. If that's the case, then the fix for this ticket would be to move this block outside of the directories loop and only add it once to the single post URL. But, perhaps there is a feature of WordPress that I'm not aware of! Even after working with it for almost 20 years, it still surprises me from time to time :-).
Can confirm that.
The post url doesn't give me 404, but there are definetely some problems.
Eg.