Support

Account

Home Forums Gutenberg Adding ACF blocks to a block template Reply To: Adding ACF blocks to a block template

  • Hi Tom,

    I was expirimenting with the same thing as i couldnt find information about this.

    But for example:

    First You create a custom block via acf_register_block:

    
    acf_register_block(
    array(
    	'name'              => 'blockname',
    	'title'             => __('title'),
    	'description'       => __('description')
    		
    ));
    

    Then you can take the name of the acf_block ‘blockname’ and use it as following in your post type template:

    
    	$post_type_object->template = array(
    		array( 'acf/blockname', array() ),		
    	);
    

    Note: If your blockname contains a space or a underscore, acf renames this to a dash, so ‘block_name’ becomes ‘block-name’.

    Hope this helps!