Created
February 26, 2024 20:35
-
-
Save greg-randall/d0b9dacad86e8d0e20a94d472a32914a to your computer and use it in GitHub Desktop.
Works like "do_shortcode" but for Gutenberg blocks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function do_gutenberg( $content ) { | |
$output_rendered = ""; | |
$parsed_blocks = parse_blocks( $content ); | |
if ( $parsed_blocks ) { | |
foreach ( $parsed_blocks as $block ) { | |
$output_rendered .= apply_filters( 'the_content', render_block( $block ) ); | |
} | |
} | |
return ( $output_rendered ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment