wp_get_first_block example


function wp_get_first_block( $blocks$block_name ) {
    foreach ( $blocks as $block ) {
        if ( $block_name === $block['blockName'] ) {
            return $block;
        }
        if ( ! empty( $block['innerBlocks'] ) ) {
            $found_block = wp_get_first_block( $block['innerBlocks']$block_name );

            if ( ! empty( $found_block ) ) {
                return $found_block;
            }
        }
    }

    return array();
}

/** * Retrieves Post Content block attributes from the current post template. * * @since 6.3.0 * @access private * * @global int $post_ID * * @return array Post Content block attributes or empty array if they don't exist. */
Home | Imprint | This part of the site doesn't use cookies.