Posts page content blocks not rendering block styles

I’ve created a page and added some ACF blocks I’ve created. For some reason the styles are not being rendered with the block when I get the posts page ID and the content from it. If I remove it from the posts page setting, the blocks render fine (with styles).

Can anybody assist with the code that would be required to get a specific page’s content and render the blocks on the page with the style as well?

Here is one example that I have tried. Any help would be greatly appreciated.

      $post = get_post(11);

{!! do_blocks($post->post_content) !!}

Your issue appears to match well with this one in Gutenberg:

1 Like

Yeah it looks like blocks that do their own styles have an assumption that they’ll run before wp_head() so they can insert styles there. On a normal theme, you can see that happen with get_the_block_template_html():

You might be able to fix it by hacking the sage index.php although this would probably have other side effects:

+ <?php $content = view(app('sage.view'), app(''))->render(); ?>
<!doctype html>
<html <?php language_attributes(); ?>>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?php wp_head(); ?>

  <body <?php body_class(); ?>>
    <?php wp_body_open(); ?>
    <?php do_action('get_header'); ?>

    <div id="app">
-      <?php echo view(app('sage.view'), app(''))->render(); ?>
+     <?php echo $content; ?>

    <?php do_action('get_footer'); ?>
    <?php wp_footer(); ?>