Skip to content

Instantly share code, notes, and snippets.

@jmichaelward
Last active April 9, 2021 13:56
Show Gist options
  • Save jmichaelward/002ebc2f613df15bd69c020d8ea1a782 to your computer and use it in GitHub Desktop.
Save jmichaelward/002ebc2f613df15bd69c020d8ea1a782 to your computer and use it in GitHub Desktop.
Render a Gravity Forms editor block on another page.
<?php
get_header();
/** @var WP_Post $page */
$page = get_post( 308 );
$blocks = parse_blocks( $page->post_content );
ob_start();
foreach ( parse_blocks( $page->post_content ) as $block ) {
echo $block['blockName'] === 'gravityforms/form' ? do_shortcode( render_block( $block ) ) : render_block( $block );
}
echo ob_get_clean();
get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment