Title: Render block somewhere else in PHP
Last modified: December 10, 2019

---

# Render block somewhere else in PHP

 *  Resolved [creativetags](https://wordpress.org/support/users/creativetags/)
 * (@creativetags)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/render-block-somewhere-else-in-php/)
 * I want to hide my block-lab block from the page content and show it in the header.
   How do I render the block in header.php?
 * In my header.php I have:
 * `<?php get_hero_banner($post->post_content) ?>`
 * In functions.php my problem is render_block_core_block
 *     ```
       function get_hero_banner($content){
       	$blocks = parse_blocks( $content );
       	$content = '';
       	foreach ($blocks as $block) {
       		if ($block['blockName'] == 'block-lab/hero') {
       			$attributes = (array) $block['attrs'];
       			$render     = render_block_core_block( $attributes );
       			$content   .= $render;
       		}
       	}
       	if ($content == '') {
       		$content = '<p>Missing block</p>';
       	}
       	return $content;
       }
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/render-block-somewhere-else-in-php/#post-12225103)
 * Hi [@creativetags](https://wordpress.org/support/users/creativetags/),
    Thanks
   for bringing that up.
 * That could be useful, but unfortunately I don’t think there’s general support
   for rendering blocks outside of post content.
 * We’re watching the discussion around this, and aware that it could be a really
   useful feature:
 * [https://wptavern.com/initial-documentation-for-block-based-wordpress-themes-proposed](https://wptavern.com/initial-documentation-for-block-based-wordpress-themes-proposed)
 *  Thread Starter [creativetags](https://wordpress.org/support/users/creativetags/)
 * (@creativetags)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/render-block-somewhere-else-in-php/#post-12227491)
 * Ok fair enough. Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Render block somewhere else in PHP’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/block-lab_5c34e8.svg)
 * [Block Lab](https://wordpress.org/plugins/block-lab/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/block-lab/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/block-lab/)
 * [Active Topics](https://wordpress.org/support/plugin/block-lab/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/block-lab/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/block-lab/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [creativetags](https://wordpress.org/support/users/creativetags/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/render-block-somewhere-else-in-php/#post-12227491)
 * Status: resolved