Support

Account

Home Forums Gutenberg ACF Blocks won't render when using register_block_template()

Solved

ACF Blocks won't render when using register_block_template()

  • Hi all, i’m trying to get an ACF block which is working fine across all Post Types and Templates to be the only Block loaded on posts (replacing the ‘Classic Block’), i’m using register_block_template() but can’t seem to include any of my ACF blocks in any templates, just give’s me a blank page with not editor rendered at all! Anyone else managed to do this?

    My code is below.

    // GUTENBERG BLOCK TEMPLATES
    function register_block_template() {
    
        //Posts
        $post_type_object_post = get_post_type_object( 'post' );
        $post_type_object_post->template = array(
            array( 'acf/editor' ),
        );
        // Lock Post Blocks
        //$post_type_object_post->template_lock = 'all';
    }
    add_action( 'init', 'register_block_template' );
  • Scrap that, I hadn’t added the Post Post Type to the Post Type array when registering the Block!

  • I’m sorry, but i’ve the same trouble i can’t find a way to solve it : always get a white page

    
    acf_register_block_type(array(
                'name'              => 'csm',
                'title'             => __('Centre de soins'),
                'description'       => __(''),
                'render_callback'   => 'acf_csm_block',
                'supports'          => array( 'align' =>false ),
                'post_types'        => array('post', 'page'),
                'mode'              => 'edit',
                'category'          => 'cnesoa',
                'icon'              => 'plus'
            ));
    function register_block_template() {
    
        //Posts
        $post_type_object_post = get_post_type_object( 'post' );
        $post_type_object_post->template = array(
            array( 'acf/csm' ),
        );
    }
    add_action( 'init', 'register_block_template' );

    What i’m doing wrong ?

    thank you

  • OK sorry, i’ve some other error on my block which break the page.
    All is right

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.