From b76864660c1b1f4fc9cad3e9ab32ee9545b9f9fb Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 12 Sep 2015 07:35:05 +0000 Subject: [PATCH] Comments: `get_comments_link()` should return a link with `#respond` as the hash instead of `#comments` if `get_comments_number()` returns `0`. Props cgrymala, wonderboymusic. Fixes #19893. git-svn-id: https://develop.svn.wordpress.org/trunk@34075 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment-template.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index 9d63bd3af9..87dc6ce37d 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -703,7 +703,8 @@ function get_comment_link( $comment = null, $args = array() ) { * @return string The link to the comments. */ function get_comments_link( $post_id = 0 ) { - $comments_link = get_permalink( $post_id ) . '#comments'; + $hash = get_comments_number( $post_id ) ? '#comments' : '#respond'; + $comments_link = get_permalink( $post_id ) . $hash; /** * Filter the returned post comments permalink. *