Skip to content

Instantly share code, notes, and snippets.

@bradpotter
Last active June 1, 2021 15:12
Show Gist options
  • Save bradpotter/a236b6f93a7b5655956b872f7cee776f to your computer and use it in GitHub Desktop.
Save bradpotter/a236b6f93a7b5655956b872f7cee776f to your computer and use it in GitHub Desktop.
Place a reusable Gutenberg block via a Genesis hook. (Where 956 is the Post ID of your reusable block)
add_action( 'genesis_before_footer', 'my_custom_query' );
function my_custom_query() {
$post_id = 956;
$queried_post = get_post($post_id);
echo $queried_post->post_content;
}
@johnstonphilip
Copy link

johnstonphilip commented Mar 31, 2021

Also may be worth mentioning that if you are using shortcodes at all in the content, you'll also need to run it through do_shortcode for those to get rendered out properly.

@johnstonphilip
Copy link

Also worth mentioning that embeds won't work with this unless you also wrap in

// Handle embeds.
global $wp_embed;
$content = $wp_embed->autoembed( $content );

This is what core does for widgets here:
https://github.com/WordPress/WordPress/blob/1314542c50e2ad2075b1304df20471febffb8fad/wp-includes/widgets/class-wp-widget-block.php#L75-L77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment