Skip to content

Commit

Permalink
Fix Post Template block to make test pass
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed May 25, 2023
1 parent 8695bd7 commit 8add1e6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/block-library/src/post-template/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ function render_block_core_post_template( $attributes, $content, $block ) {
while ( $query->have_posts() ) {
$query->the_post();

// Get an instance of the current Post Template block.
$block_instance = $block->parsed_block;

// Set the block name to one that does not correspond to an existing registered block.
// This ensures that for the inner instances of the Post Template block, we do not render any block supports.
$block->name = 'core/null';
$block_instance['blockName'] = 'core/null';

$post_id = get_the_ID();
$post_type = get_post_type();
Expand All @@ -92,7 +95,7 @@ function render_block_core_post_template( $attributes, $content, $block ) {
add_filter( 'render_block_context', $filter_block_context );
// Render the inner blocks of the Post Template block with `dynamic` set to `false` to prevent calling
// `render_callback` and ensure that no wrapper markup is included.
$block_content = $block->render( array( 'dynamic' => false ) );
$block_content = ( new WP_Block( $block_instance ) )->render( array( 'dynamic' => false ) );
remove_filter( 'render_block_context', $filter_block_context );

// Wrap the render inner blocks in a `li` element with the appropriate post classes.
Expand Down

0 comments on commit 8add1e6

Please sign in to comment.