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
in block inside single post template
class="bs-exhibdate-block-acf__innerblocks"
template="' . esc_attr( wp_json_encode( $bsdates_inner_blocks_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?
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.