[wp-trac] [WordPress Trac] #63580: render_block does not render innerblocks when used explicitly
WordPress Trac
noreply at wordpress.org
Thu Jul 17 12:35:03 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 lakshyajeet):
== Reproduction Report
=== Description
This report validates whether the issue can be reproduced.
=== Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.29
- Server: nginx/1.29.0
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.29)
- Browser: Chrome 137.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.3
- MU Plugins: None activated
- Plugins:
* Test Reports 1.2.0
=== Actual Results
1. ✅ Error condition occurs, the bug can be reproduced.
=== Additional Notes
When programmatically defining WordPress block structures and rendering
them using `render_block()`, inner blocks (nested blocks) are not rendered
if their direct parent block (or any ancestor in the block tree) is
missing the `innerContent` array in its block definition.
Specifically, if a block array has `innerBlocks` populated but lacks an
`innerContent` array (or if the `innerContent` array does not contain the
correct integer indices corresponding to its `innerBlocks`), the children
blocks will not appear in the final rendered output.
This behavior was observed with `core/group`, and `core/column` blocks.
=== Supplemental Artifacts
Code that reproduces the issue (blocks **not** rendered):
{{{#!php
<?php
$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],
],
[
'blockName' => 'core/group',
'attrs' => [],
'innerBlocks' => [$second_column_blocks],
],
],
];
add_action('template_redirect', function() {
global $column_layout_block;
echo apply_filters('the_content',
render_block($column_layout_block));
// Expected: Group Block gets rendered
// Actual Result: Nothing is rendered
});
?>
}}}
Code that works correctly (blocks are rendered):
{{{#!php
<?php
$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' => [
'<p>First Group Inner</p>',
],
],
[
'blockName' => 'core/group',
'attrs' => [],
'innerBlocks' => [$second_column_blocks],
'innerContent' => [
'<p>Second Group Inner</p>',
],
],
],
'innerContent' => [
'<p>First Group Content</p>'
'<p>Second Group Content</p>'
]
];
add_action('template_redirect', function() {
global $column_layout_block;
echo apply_filters('the_content',
render_block($column_layout_block));
// Result: Blocks are rendered when innerContent is provided.
// First Group Content
// Second Group Content
});
?>
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63580#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list