do_blocks and missing inner html content

Support General do_blocks and missing inner html contentResolved

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #41275
    Nicholas CoxNicholas Cox
    Participant

    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}} /-->

    #41285
    PeterPeter
    Moderator

    Hello,

    Thank you for your feedback.

    I'm checking the issue and get back to you later.

    #41297
    Nicholas CoxNicholas Cox
    Participant

    thanks, just wanted to render out the blocks for a custom app using the rest api.

    #41299
    PeterPeter
    Moderator

    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.

    #41300
    Nicholas CoxNicholas Cox
    Participant

    Hi, I just want to render the block html on the front end of my site using my theme template using do_blocks()

    #41301
    Nicholas CoxNicholas Cox
    Participant

    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}} /-->
    
    #41307
    PeterPeter
    Moderator

    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

    #41341
    Nicholas CoxNicholas Cox
    Participant

    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.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.