diff --git a/packages/block-library/src/post-excerpt/index.php b/packages/block-library/src/post-excerpt/index.php index 03e0acf4fe22a..cc68b24df971a 100644 --- a/packages/block-library/src/post-excerpt/index.php +++ b/packages/block-library/src/post-excerpt/index.php @@ -18,6 +18,12 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) { return ''; } + $excerpt = get_the_excerpt( $block->context['postId'] ); + + if ( empty( $excerpt ) ) { + return ''; + } + $more_text = ! empty( $attributes['moreText'] ) ? '' . $attributes['moreText'] . '' : ''; $filter_excerpt_more = function( $more ) use ( $more_text ) { return empty( $more_text ) ? $more : ''; @@ -38,7 +44,7 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) { } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); - $content = '

' . get_the_excerpt( $block->context['postId'] ); + $content = '

' . $excerpt; $show_more_on_new_line = ! isset( $attributes['showMoreOnNewLine'] ) || $attributes['showMoreOnNewLine']; if ( $show_more_on_new_line && ! empty( $more_text ) ) { $content .= '

' . $more_text . '

';