Skip to content
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

Get InnerBlocks content in the render function in php #26384

Closed
rosa-hai opened this issue Oct 22, 2020 · 2 comments
Closed

Get InnerBlocks content in the render function in php #26384

rosa-hai opened this issue Oct 22, 2020 · 2 comments
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@rosa-hai
Copy link

Hi,
I'd like to use InnerBlock in my custom plugin created dynamically. I'm using the edit function in js to render in the editor and the render function in the php file to render in front. I can pass attributes between the two functions but I don't know how to pass the InnerBlock content to the php file. I searched and only found answers using the save function in js. Is it possible to pass the InnerBlock content to php?

Thanks

@talldan talldan added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Oct 23, 2020
@talldan
Copy link
Contributor

talldan commented Oct 23, 2020

Hi @rosa-hai,

I don't think this is documented yet, but you should be able to use a third $block argument in your render callback. An example of this is the navigation block in the Gutenberg plugin:
https://github.com/WordPress/gutenberg/blob/master/packages/block-library/src/navigation/index.php#L106

You can then loop through the inner_blocks property and render each block:

$inner_blocks_html = '';
foreach ( $block->inner_blocks as $inner_block ) {
$inner_blocks_html .= $inner_block->render();
}

@rosa-hai
Copy link
Author

Oh yes I'll have a look thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

2 participants