title: How can I show only specific block from post on front page?
body: <p>I'm creating a custom header block for a theme. It generates a special layout out of three different images and text. When a post contains this block it should only show this block on the front page. I found a solution that works but seems dirty and also I would like to encapsulate this within the block plugin and not the theme.</p>
  
  <p>Current solution in theme (in content.php):</p>
  
  <pre><code>$content = get_the_content();
  
  if( !is_frontpage() &amp;&amp; has_blocks( $content ) ) {
  
    $blocks = parse_blocks( $content );
  
    if ( !empty($blocks) &amp;&amp; $blocks[0]['blockName'] === 'namespace/block' ) {
      echo $blocks[0]['innerHTML'];
    }
    else {
      the_content();
    }
  }
  </code></pre>
  
  <p>I also tried to integrate it within the plugin file:</p>
  
  <pre><code>function namespace_block_frontpage_blocks($content) {
    if( is_front_page() &amp;&amp; has_blocks( $content ) ) {
      $blocks = parse_blocks( $content );
      if ( !empty($blocks) &amp;&amp; $blocks[0]['blockName'] === 'namespace/block' ) {
        return $blocks[0]['innerHTML'];
      }
    }
    return $content;
  }
  add_filter( 'the_content','namespace_block_frontpage_blocks' );
  </code></pre>
  
  <p>But this doesn't work since 'has_blocks' returns false and 'parse_blocks' doesn't return anything.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I found a solution. You need to give the add_filter function a priority (third parameter):</p>
  
  <pre><code>add_filter( 'the_content','namespace_block_frontpage_blocks', 0 );
  </code></pre>