• Resolved charlie67p

    (@charlie67p)


    Hi,

    Is it possible to use the blocks I made with CBB in a Post template?

    For example, to automatically add my-CBB-block when creating a new Post, after the gallery block :

    function my_add_template_to_posts()
    {
    	$post_type_object = get_post_type_object('post');
    	$post_type_object->template = [
    		['core/gallery', [
    			'align' => 'center',
    			'linkTo' => 'media',
    			'sizeSlug' => 'mini-thumb',
    			'allowResize' => true,
    			'imageCrop' => false
    		]],
    		['wp:boldblocks/my-CBB-block', [
    			'placeholder' => 'Content of my CBB block',
    		]]
    		
    	];
    	$post_type_object->template_lock = false;
    }
    add_action('init', 'my_add_template_to_posts');

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Phi Phan

    (@mr2p)

    @charlie67p, Yes, you can. However, you have to use it as boldblocks/my-CBB-block, not wp:boldblocks/my-CBB-block. CBB blocks are only layout blocks, similar to core/group and others. They do not have content attributes, so you can use them exactly as you would use core/group.

    Phi.

    • This reply was modified 8 months, 1 week ago by Phi Phan.
    Thread Starter charlie67p

    (@charlie67p)

    Perfect. Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘use a CBB block in Post Block Template?’ is closed to new replies.