diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 18f3fdff4a..0c7f40981a 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -682,16 +682,13 @@ function comments_link( $deprecated = '', $deprecated_2 = '' ) { * @return int The number of comments a post has. */ function get_comments_number( $post_id = 0 ) { - $post_id = absint( $post_id ); + $post = get_post( $post_id ); - if ( !$post_id ) - $post_id = get_the_ID(); - - $post = get_post($post_id); - if ( ! isset($post->comment_count) ) + if ( ! isset( $post->comment_count ) ) { $count = 0; - else + } else { $count = $post->comment_count; + } /** * Filter the returned comment count for a post.