From 7e9a24affe106b0aabaa2a4ba529eff508778805 Mon Sep 17 00:00:00 2001 From: Ian Dunn Date: Thu, 4 Nov 2021 08:49:49 -1000 Subject: [PATCH] Post Template. Return `No results found` in PHP to match JS. --- packages/block-library/src/post-template/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/post-template/index.php b/packages/block-library/src/post-template/index.php index 45bf3c4c64602e..2b0bb6503952b2 100644 --- a/packages/block-library/src/post-template/index.php +++ b/packages/block-library/src/post-template/index.php @@ -36,10 +36,6 @@ function render_block_core_post_template( $attributes, $content, $block ) { $query = new WP_Query( $query_args ); - if ( ! $query->have_posts() ) { - return ''; - } - $classnames = ''; if ( isset( $block->context['displayLayout'] ) && isset( $block->context['query'] ) ) { if ( isset( $block->context['displayLayout']['type'] ) && 'flex' === $block->context['displayLayout']['type'] ) { @@ -49,6 +45,10 @@ function render_block_core_post_template( $attributes, $content, $block ) { $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) ); + if ( ! $query->have_posts() ) { + return "

" . __( 'No results found.' ) . '

'; + } + $content = ''; while ( $query->have_posts() ) { $query->the_post();