Want to get Gutenberg Blocks without the_content()? Add the following code to the functions.php file of your current activated WordPress theme.
1 2 3 4 5 6 7 8 9 10 11 | $post_id = 1; $post = get_post( $post_id ); if ( has_blocks( $post->post_content ) ) { $blocks = parse_blocks( $post->post_content ); print_r($blocks); foreach( $blocks as $block ) { echo render_block( $block ); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.