diff --git src/wp-includes/comment-template.php src/wp-includes/comment-template.php
index dc63e36..afa9fd8 100644
--- src/wp-includes/comment-template.php
+++ src/wp-includes/comment-template.php
@@ -835,13 +835,13 @@ function comments_link( $deprecated = '', $deprecated_2 = '' ) {
  * @since 1.5.0
  *
  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
- * @return int The number of comments a post has.
+ * @return string The number of comments a post has. Numeric string is returned for compatibility reasons.
  */
 function get_comments_number( $post_id = 0 ) {
 	$post = get_post( $post_id );
 
 	if ( ! $post ) {
-		$count = 0;
+		$count = '0';
 	} else {
 		$count = $post->comment_count;
 		$post_id = $post->ID;
diff --git tests/phpunit/tests/comment/template.php tests/phpunit/tests/comment/template.php
index ce93be2..ab67b82 100644
--- tests/phpunit/tests/comment/template.php
+++ tests/phpunit/tests/comment/template.php
@@ -17,6 +17,19 @@ class Tests_Comment_Template extends WP_UnitTestCase {
 		$this->assertEquals( 12, get_comments_number( get_post( $post_id ) ) );
 	}
 
+	function test_get_comments_number_return_type() {
+		$post_id = self::factory()->post->create();
+
+		$this->assertSame( '0', get_comments_number( 0 ) );
+		$this->assertSame( '0', get_comments_number( $post_id ) );
+		$this->assertSame( '0', get_comments_number( get_post( $post_id ) ) );
+
+		self::factory()->comment->create_post_comments( $post_id, 12 );
+
+		$this->assertSame( '12', get_comments_number( $post_id ) );
+		$this->assertSame( '12', get_comments_number( get_post( $post_id ) ) );
+	}
+
 	function test_get_comments_number_without_arg() {
 		$post_id = self::factory()->post->create();
 		$permalink = get_permalink( $post_id );
