What I am trying to do is to use specific Reusable Blocks, that are editable by certain admins in the back end, within block templates for custom post types. So if you register a CTP or edit the capabilities of standard post types, you can use them like:

    function create_add_post_types() {
    register_post_type( 'product',
    array(
      'public' => true,
      'capability_type' => 'page',
      'show_in_rest' => true,
      'template' => array(
            array( 'core/heading', array(
                   'placeholder' => 'Füge eine Überschrift hinzu',
                   'content' => 'Projektname - Stadt, Land',
                   'level' => 1,
            ) ),
        )
    );
    }
    add_action( 'init', 'create_add_post_types' );

..except that insteadt of a core block like the heading here a reusable block is called.

2 s
2

I actually found a solution myself by following the way a reusable block is registered in this stackexchange thread:

Reusable blocks are all stored in/as core/block and this block has the attribute ref which carries the post id of that block.

So, you can use

array( 'core/block', array(
 'ref' => [your block ID],
) ),

and the ID of every registered block is visible via the URL of that block at [your-wordpress]/wp-admin/edit.php?post_type=wp_block

Leave a Reply

Your email address will not be published. Required fields are marked *