[wp-trac] [WordPress Trac] #63580: render_block does not render innerblocks when used explicitly
WordPress Trac
noreply at wordpress.org
Thu Jul 17 14:03:06 UTC 2025
#63580: render_block does not render innerblocks when used explicitly
--------------------------+------------------------------
Reporter: yashjawale | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: trunk
Severity: normal | Resolution:
Keywords: 2nd-opinion | Focuses:
--------------------------+------------------------------
Comment (by iamadisingh):
== Reproduction Report
=== Description
This report validates whether the issue can be reproduced.
=== Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.3
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
- Browser: Chrome 138.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.2
- MU Plugins: None activated
- Plugins:
* Test Render Block Issue 1.0.0
* Test Reports 1.2.0
=== Actual Results
1. ✅ Error condition occurs (reproduced).
=== Additional Notes
- When using `render_block()` explicitly with programmatically created
block structures, nested blocks (`innerBlocks`) are not rendered if the
parent block lacks an `innerContent` array. This affects container blocks
like `core/column` and `core/columns` where the parent block should render
its child blocks even without explicit innerContent markup.
- Parent blocks with `innerBlocks` should render their child blocks
regardless of whether innerContent is defined, as the child blocks contain
valid `innerHTML` and `innerContent` properties.
- The issue lies in how WordPress's `WP_Block::render()` method processes
blocks. The fix should be in the `WP_Block::render()` method to ensure
that `innerBlocks` are processed even when innerContent is empty, while
maintaining backward compatibility with existing behavior.
=== Supplemental Artifacts
Plugin code used for reproducing the error
{{{#!php
<?php
/**
* Plugin Name: Test Render Block Issue
* Description: A plugin to test rendering of blocks with inner blocks.
* Version: 1.0.0
*/
$first_column_blocks = [
'blockName' => 'core/paragraph',
'attrs' => [],
'innerBlocks' => [],
'innerHTML' => '<p>First Global HTML</p>',
'innerContent' => [
'<p>First Global HTML</p>',
],
];
$second_column_blocks = [
'blockName' => 'core/paragraph',
'attrs' => [],
'innerBlocks' => [],
'innerHTML' => '<p>Second Global HTML</p>',
'innerContent' => [
'<p>Second Global HTML</p>',
],
];
$column_layout_block = [
'blockName' => 'core/columns',
'attrs' => [],
'innerBlocks' => [
[
'blockName' => 'core/group',
'attrs' => [],
'innerBlocks' => [$first_column_blocks],
'innerContent' => [
null,
],
],
[
'blockName' => 'core/group',
'attrs' => [],
'innerBlocks' => [$second_column_blocks],
'innerContent' => [
null,
],
],
],
'innerContent' => [ null, null] // Required without this nested blocks
won't render
];
add_action('template_redirect', function() {
global $column_layout_block;
echo apply_filters('the_content', render_block($column_layout_block));
});
}}}
When innerContent is added - https://files.catbox.moe/j1qdyr.png
Without innerContent - https://files.catbox.moe/mitk2k.png
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63580#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list