Remove Post Title if First Block is Hero Block

// Remove page title if first block is the acf-hero-block
function wd_remove_entry_title() {

	global $post;

     // check if the post is using the block editor
     if ( has_blocks( $post->post_content ) ) {
         $blocks = parse_blocks( $post->post_content );

         // check if the first block is the 'acf-hero-block'
         if ( $blocks[0]['blockName'] === 'acf/acf-hero-block' ) {

              // remove the page title if first block is the acf-hero-block
              remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
              remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
              remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );



add_action( 'genesis_before_entry', 'wd_remove_entry_title' );

About Matt Whiteley

Matt has been building bespoke WordPress websites for over 10 years specializing in the Genesis Framework. He integrates Advanced Custom Fields heavily in all builds, especially with the new Gutenberg Block Editor, allowing clients to easily modify all aspects of the their website with ease.

He works with a wide variety of small businesses and agencies across the country providing development services as well as hosting and maintenance. When he isn't coding he enjoys spending time with his wife and two children, golfing and playing poker.