Opened 14 years ago
Closed 10 years ago
#19893 closed enhancement (fixed)
get_comments_link() doesn't link properly if there are no responses
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.4 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Comments | Keywords: | has-patch needs-unit-tests commit |
| Focuses: | Cc: |
Description
Since the current implementation of get_comments_link() simply returns the permalink with #comments appended to the end of it, and the HTML element with an ID of comments only exists when existing comments are wrapped inside of it, it doesn't lead to anything when there are 0 comments on the post.
I've attached a patch that checks whether there are any comments on the post or not; and, if not, it appends #respond to the end of the link; otherwise it appends #comments.
Attachments (3)
Change History (11)
#1
@
14 years ago
In the bundled themes (and I suspect most other themes as well), #respond is a descendant of #comments anyway, so this wouldn't make any difference?
#2
@
14 years ago
I was going by the code included in wp-includes/theme-compat/comments.php, which uses #comments as an ID for the <h3> tag at the top of the comment list. That <h3> is only output when have_comments() is true (it's not wrapping anything, and doesn't even exist if there are no comments).
I realize that that file is deprecated, but if that's the way WordPress builds the comment area by default, that might be the way a lot of people are using it.
#3
@
11 years ago
- Keywords dev-feedback needs-refresh added; has-patch removed
- Severity changed from minor to normal
Needs refresh because of #19210
#4
@
10 years ago
- Keywords has-patch added; dev-feedback needs-refresh removed
- Milestone changed from Awaiting Review to 4.4
Makes a lot of sense: [attached:19893.diff refreshed]
#5
@
10 years ago
- Owner set to wonderboymusic
- Resolution set to fixed
- Status changed from new to closed
In 34075:
#6
@
10 years ago
- Keywords needs-unit-tests added
Looks like Tests_Feed_RSS2::test_items is failing after this change.
Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'http://example.org/?p=27#comments' +'http://example.org/?p=27#respond'
#7
@
10 years ago
- Keywords commit added
- Resolution fixed deleted
- Status changed from closed to reopened
19893.2.diff fixes the comment link response in Tests_Feed_RSS2::test_items() as there are no comments created for the created posts in this test, therefore per r34075 the comment link to each post in the test should end in #respond and not #comment
get_comments_link() checks number of comments before generating link