Last active
April 9, 2021 13:56
-
-
Save jmichaelward/002ebc2f613df15bd69c020d8ea1a782 to your computer and use it in GitHub Desktop.
Render a Gravity Forms editor block on another page.
This file contains hidden or 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
<?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