-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gutenberg_render_block does not render inner blocks #8214
Comments
…rendering of inner blocks - WordPress#8214
Testing this again WordPress 5.0.3 and in mind of #11334, the original issue of inner blocks not being included in the rendered markup has been resolved. The two contents are not identical, but only in that the comment demarcations are removed during the "render" (expected). Script: $content = <<<HTML
<!-- wp:columns -->
<div class="wp-block-columns has-2-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:paragraph -->
<p>This is a column</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column -->
<!-- wp:column -->
<div class="wp-block-column"><!-- wp:paragraph -->
<p>This is the other column</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->
HTML;
$blocks = parse_blocks( $content );
$new_content = '';
foreach( $blocks as $block ) {
$new_content .= render_block( $block );
}
var_export( $new_content ); Output: <div class="wp-block-columns has-2-columns">
<div class="wp-block-column">
<p>This is a column</p>
</div>
<div class="wp-block-column">
<p>This is the other column</p>
</div>
</div> Closing this as fixed, but let's plan to reopen if it continues to be an issue, or open separate issues if further improvements are necessary. |
A possibly related issue arises when using InnerBlocks with custom post types set to be the front page of a site via the Reading settings in the backend. If that custom post type piece of content has InnerBlocks in them, they are not rendered using the usual the_content function call in a template part. Using do_blocks and passing the content to it does render all the InnerBlocks. Steps to reproduce:
code below does not work:
following code does work:
the issue here #8019 was what I eventually use to resolve this. |
@ryanapsmith I would expect your original (non-working) code snippet should not be effectively any different than the second (working) one, at least as far as blocks processing is concerned. It may be a matter of how you The
|
@aduth will explore the get_the_ID angle a bit more, thanks! |
Describe the bug
gutenberg_render_block
does not render inner blocksTo Reproduce
Use Gutenberg editor to add 2 columns. You end up with something like this
Use
gutenberg_parse_blocks
and thengutenberg_render_block
to re-generate the content.Expected behaviour
$new_content
should be the same as$content
but it's not. The inner blocks of columns is not rendered.Desktop (please complete the following information):
Additional context
Gutenberg version 3.3.0
The text was updated successfully, but these errors were encountered: