Support

Account

Home Forums Gutenberg Markup after InnerBlocks stripped out in Block Preview Reply To: Markup after InnerBlocks stripped out in Block Preview

  • I am using a php render template, and I have put

    <div>
    <?php
    echo ‘<InnerBlocks template=”‘ . esc_attr( wp_json_encode( $template ) ) . ‘” templateLock=”all” />’;
    ?>
    </div>
    <div>
    <?php
    // Check rows exists.
    if ( have_rows( ‘card’ ) ):
    // Loop through rows.
    while ( have_rows( ‘card’ ) ): the_row();
    // Load sub field value.
    if ( get_sub_field( ‘image’ ) ) {
    $image = get_sub_field( ‘image’ );
    $image_id = $image[ ‘id’ ];
    $image_alt = $image[ ‘alt’ ];
    } else {
    $image_id = ‘152’;
    $image_alt = ‘placeholder image’;
    }
    $text_background_colour = get_sub_field( ‘text_background_colour’ );
    $title = get_sub_field( ‘title’ );
    $sentence = get_sub_field( ‘sentence’ );
    // Do something…
    ?>
    <figure>
    <?php
    echo wp_get_attachment_image( $image_id, ‘full’, false, array(
    ‘data-sizes’ => ‘auto’,
    ‘alt’ => $image_alt
    ) );
    ?>
    </figure>
    <p><?php echo esc_html($text_background_colour); ?></p>
    <p><?php echo esc_html($title); ?></p>
    <p><?php echo esc_html($sentence); ?></p>
    <?php
    // End loop.
    endwhile;
    // No value.
    else :
    // Do something…
    endif;
    ?>
    </div>

    I found that if I put my content that should appear after the inner blocks into a completely separate div, it does appear in preview, even without the </innerblocks> closing tag. However, if I put it in the same div as the inner blocks, it does not appear in the preview.