From 8686244d5dbd1fbce897919d4d75817a5810c045 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 19 Mar 2020 10:54:51 +0100 Subject: [PATCH] Use the default post comments template for the post comments listing --- .../block-library/src/post-comments/index.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/block-library/src/post-comments/index.php b/packages/block-library/src/post-comments/index.php index d9f35117a74da..88405e8cb586b 100644 --- a/packages/block-library/src/post-comments/index.php +++ b/packages/block-library/src/post-comments/index.php @@ -15,17 +15,18 @@ function render_block_core_post_comments() { if ( ! $post ) { return ''; } - $comments = get_comments( - array( - 'post_id' => $post->ID, - ) - ); - $output = ''; - // TODO: Handle nested comments. - foreach ( $comments as $comment ) { - $output .= '

' . $comment->comment_author . '
' . $comment->comment_content . '

'; - } - return $output; + + ob_start(); + // This generates a deprecate message. + // Ideally this deprecation is removed. + comments_template(); + ob_get_clean(); + + ob_start(); + wp_list_comments( array( 'page' => $post->ID ) ); + $comments = ob_get_clean(); + + return $comments; } /**