Opened 22 months ago
Closed 22 months ago
#18259 closed enhancement (worksforme)
Comment_ID() should be relative to the article
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Comments | Version: | 3.2.1 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
After posting a comment, the anchor to the comment_ID is attached to the URL to send the user to his new comment.
This comment_ID should be relative to the article instead of showing the ID of the last comment in our wordpress DB.
i.e. I'm getting "<li id="comment-4833" ..." in an article that has two comments. And the URL is: "http://domain.ltd/post-name#comment4833", when it should be "http://domain.ltd/post-name#comment2"
The code:
<li <?php if($depth > 1) {echo comment_class('comment-replied');} else {echo comment_class();}; ?> id="comment-<?php comment_ID() ?>">
Change History (6)
It's a matter of semantics. A #4833 ID doesn't add any meaning to the anchor/URL.
Regards
I do not think it worths the effort for doing this in the core. This functionality depends on how themes are coded, for example some of them show the trackbacks/pingbacks in the comment list, others do not. The problem is, when a comment is posted, you would not have a reliable way to determine the last relative id to do the redirection.
You can do it in your theme, though. You have the comment_post_redirect filter to modify the url used after posting a comment.
With comment_post_redirect I cannot add a custom ID relative to the number of comments in the post. Do you think is it possible to pass that info to the filter?
- Keywords close added; needs-patch removed
Sure, with the use of wp_count_comments.

Marking as an enhancement because it's not a bug, it's intentionally.
Also why do you need this? If it's #2 or #9999, all the same to me. The main point is that it scrolls to the comment.