This is for instances where you want to extract a block out of a typical layout (say a hero when the following content is laid out differently).
function display_hero() {
global $post;
$blocks = parse_blocks( $post->post_content );
foreach( $blocks as $block ) {
if( 'acf/page-header' === $block['blockName'] ) {
echo render_block( $block );
break;
}
}
}
To then display the remaining content WITHOUT that singular block, utilize the following:
<?php
$blocks = parse_blocks( $post->post_content );
foreach ( $blocks as $block ) {
if ($block['blockName'] !== 'acf/page-header') {
echo render_block($block);
}
} ?>