Support

Account

Home Forums Gutenberg InnerBlocks in Block Theme template

Unread

InnerBlocks in Block Theme template

  • I sthere a way to use an ACF block template that outputs to InnerBlocks inside a Block Theme template?

    Even when I put the InnerBlocks output inside a php echo, the actual output seems to be pre-rendered in the template file, not picking up the meta data of the post that uses the template.

    It’s quite frustrating, as anything else using PHP (echo $value or even print_r($inner_blocks_template) shows all the correct data.

    Img 1 = print_r($inner_blocks_template) in block inside single post template
    Img 2 = <?php echo '<InnerBlocks
    class="bs-exhibdate-block-acf__innerblocks"
    template="' . esc_attr( wp_json_encode( $bsdates_inner_blocks_template ) ) . '"
    />'; ?>
    in block inside single post template

    Only way I’ve gotten it to work is with echo do_block, wich is even more cumbersome to use than InnerBlocks:
    <?php echo do_blocks('<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20","bottom":"var:preset|spacing|20","left":"var:preset|spacing|20","right":"var:preset|spacing|20"},"margin":{"top":"var:preset|spacing|20","bottom":"var:preset|spacing|20"},"blockGap":"var:preset|spacing|20"}},"className":"exhibdates","layout":{"type":"flex","flexWrap":"nowrap"}} -->
    <div class="wp-block-group exhibdates" style="margin-top:var(--wp--preset--spacing--20);margin-bottom:var(--wp--preset--spacing--20);padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><!-- wp:paragraph -->
    <p>' . $exhibstart . '</p>
    <!-- /wp:paragraph --> (etc)

    Am I missing something simple, or is that just how this InnerBlocks stuff works?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.