From ae28205739758fcd74c88a1df1453e451f45a76e Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Thu, 19 Sep 2024 10:56:32 +0100 Subject: [PATCH 1/3] Replace query_posts() with set() --- packages/block-library/src/post-template/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/post-template/index.php b/packages/block-library/src/post-template/index.php index 64cdd156a54310..8a4b33ef7e8a09 100644 --- a/packages/block-library/src/post-template/index.php +++ b/packages/block-library/src/post-template/index.php @@ -67,7 +67,7 @@ function render_block_core_post_template( $attributes, $content, $block ) { // If in a single post of any post type, default to the 'post' post type. if ( is_singular() ) { - query_posts( array( 'post_type' => 'post' ) ); + $query->set( 'post_type', 'post' ); } } else { $query = $wp_query; From b858a158c4edfa2162540eecd4f954c8a118db09 Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Thu, 19 Sep 2024 11:42:02 +0100 Subject: [PATCH 2/3] Fix test_rendering_post_template_with_main_query_loop_already_started test --- phpunit/blocks/render-post-template-test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/blocks/render-post-template-test.php b/phpunit/blocks/render-post-template-test.php index 6241f6f0605164..e929e459654fe7 100644 --- a/phpunit/blocks/render-post-template-test.php +++ b/phpunit/blocks/render-post-template-test.php @@ -122,7 +122,7 @@ public function test_rendering_post_template_with_main_query_loop_already_starte global $wp_query, $wp_the_query; // Query block with post template block. - $content = ''; + $content = ''; $content .= ''; $content .= ''; $content .= ''; From b4a347b88ddb094ec34fbcd22e061af1038c6f59 Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Fri, 20 Sep 2024 09:51:27 +0100 Subject: [PATCH 3/3] Remove is_singular check --- packages/block-library/src/post-template/index.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/block-library/src/post-template/index.php b/packages/block-library/src/post-template/index.php index 8a4b33ef7e8a09..9126355c096a57 100644 --- a/packages/block-library/src/post-template/index.php +++ b/packages/block-library/src/post-template/index.php @@ -64,11 +64,6 @@ function render_block_core_post_template( $attributes, $content, $block ) { if ( in_the_loop() ) { $query = clone $wp_query; $query->rewind_posts(); - - // If in a single post of any post type, default to the 'post' post type. - if ( is_singular() ) { - $query->set( 'post_type', 'post' ); - } } else { $query = $wp_query; }