Support Forum
Hi
I am trying to output a block using do_blocks($blockcontent) https://developer.wordpress.org/reference/functions/do_blocks/
and the output does not include the innerHTML content, do you know why this is? I ask as the core blocks successfully output the innerHTML.
Thanks
e.g. of $blockcontent
<!-- wp:meta-box/dc-favourite-button-block {"id":"mb-block-0634ff4f-9fee-4024-a2b6-6c29dd19e46b","data":{"button_text":"\u0026#x2764;","button_text_colour":"#1e73be","button_text_colour_active":"#8224e3","favourite_type":"product","favourite_database_check":1,"default_favourite_value":0}} /-->
Hello,
Thank you for your feedback.
I'm checking the issue and get back to you later.
thanks, just wanted to render out the blocks for a custom app using the rest api.
Hello,
What do you mean the innerHTML content in your case? It depends on the template that you use to output the custom block on your site. Or do you mean the inner blocks? I see the function do_blocks()
also renders the inner blocks as well.
Hi, I just want to render the block html on the front end of my site using my theme template using do_blocks()
So take the following block html block code and output the html.
<!-- wp:meta-box/dc-favourite-button-block {"id":"mb-block-0634ff4f-9fee-4024-a2b6-6c29dd19e46b","data":{"button_text":"\u0026#x2764;","button_text_colour":"#1e73be","button_text_colour_active":"#8224e3","favourite_type":"product","favourite_database_check":1,"default_favourite_value":0}} /-->
Hello,
Can you please share a screenshot or the code that you use to render the block? Here is an example on my demo site:
$content = '<!-- wp:meta-box/block-meta {"id":"mb-block-013da68d-63fa-4783-be27-126100bac665","data":{"first_name1":"Meta Box"}} -->
<!-- wp:heading -->
<h2 class="wp-block-heading">This is the heading text</h2>
<!-- /wp:heading -->
<!-- /wp:meta-box/block-meta -->';
echo do_blocks( $content );
Code to render the block https://monosnap.com/file/N8eBWEtGhkpcvya5Ot8Sv28GfOxnWA
what it displays on the frontend https://monosnap.com/file/zcEfNCjiRuqIMZGAhjk7sD3c5m79Fr
Hi,
thanks for the example, i have resolved my issue, it turns out there was nothing wrong with the code, i was running it too early inside my custom plugin, this returned a empty value, my bad.
sorry to have wasted your time.