Last active
June 1, 2021 15:12
-
-
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)
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
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; | |
} |
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.
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
You may want to run this through
do_blocks
like this:Additionally, for security reasons it's a good practice to wrap all output in a proper escape function:
https://developer.wordpress.org/themes/theme-security/data-sanitization-escaping/#escaping-securing-output