Support

Account

Home Forums Gutenberg Access innerBlocks in parent

Solving

Access innerBlocks in parent

  • Is there a way to access the data of <innerBlocks /> in the parent block render template? For example, a wrapper block that contains a number of item blocks in <innerBlocks /> being able to know the number of items as well as the value of the “Label” field and the inner block’s block ID.

  • It’s the $content parameter in the template.

  • No, the information you need is in the $context argument of the render callback function.
    $content contains the html of the innerBlocks.

    function render_callback_function( $block, $content, $is_preview, $post_id, $context ) {
    print_r($context);
    }

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.