Created
March 12, 2019 15:40
-
-
Save neverything/28306e674f551151f8670f63a548c0cc to your computer and use it in GitHub Desktop.
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
<?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