Skip to content

Commit

Permalink
Query Loop: Remove is_singular() check and fix test (#65483)
Browse files Browse the repository at this point in the history
* Replace query_posts() with set()

* Fix test_rendering_post_template_with_main_query_loop_already_started test

* Remove is_singular check

Co-authored-by: mikachan <[email protected]>
Co-authored-by: jffng <[email protected]>
Co-authored-by: David Herrera <[email protected]>
  • Loading branch information
4 people authored and gutenbergplugin committed Sep 20, 2024
1 parent a51babc commit 3215aa5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions packages/block-library/src/post-template/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_posts( array( 'post_type' => 'post' ) );
}
} else {
$query = $wp_query;
}
Expand Down
2 changes: 1 addition & 1 deletion phpunit/blocks/render-post-template-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<!-- wp:query {"query":{"inherit":true}} -->';
$content = '<!-- wp:query {"query":{"inherit":false}} -->';
$content .= '<!-- wp:post-template {"align":"wide"} -->';
$content .= '<!-- wp:post-title /-->';
$content .= '<!-- /wp:post-template -->';
Expand Down

0 comments on commit 3215aa5

Please sign in to comment.