Skip to content

Instantly share code, notes, and snippets.

@neverything
Created March 12, 2019 15:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neverything/28306e674f551151f8670f63a548c0cc to your computer and use it in GitHub Desktop.
Save neverything/28306e674f551151f8670f63a548c0cc to your computer and use it in GitHub Desktop.
<?php
/**
* Renders content before the blog starts. Using a reusable gutenberg block.
*/
function generate_blog_intro() {
/**
* Make sure we are on the posts page.
*/
if ( is_home() ) {
/**
* Get the raw post object from reusable blocks.
*/
$block_post = get_post( 999 );
/**
* Only render if the post exists.
*/
if ( ! is_wp_error( $block_post ) ) {
/**
* Re-renders all the blocks in the content of the post.
*/
echo do_blocks( $block_post->post_content );
}
}
}
add_action( 'generate_before_main_content', 'generate_blog_intro' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment