Developing custom blocks in WordPress Gutenberg editor can be a challenging but rewarding experience. As developers, we often need advanced access to InnerBlocks for advanced block development. In this tutorial, I will discuss how to get access to InnerBlocks attributes within the parent block.
Accessing InnerBlocks on JavaScript Edit Component
Accessing all InnerBlocks within the block Edit component is quite easy. By using the @wordpress/data module, you can access them by using the following code:
Accessing InnerBlocks on PHP Block Render Function
The WP_Block class can be accessed during the PHP block render, which gives you wide control and access over the block output. Below is an example of how you can easily access inner block attributes on the parent block render function.
Conclusion
In this tutorial, I have discussed how to get advanced access to InnerBlocks within the parent block in WordPress Gutenberg editor. With these techniques, you can create more advanced custom blocks with ease. I hope you found this tutorial helpful and informative. If you have any questions or suggestions, please feel free to leave a comment below.
Leave a Reply