Set custom post type to load custom block pattern by default

When you call register_post_type() to register your custom post type, one of the args is called template which is described as follows:

Array of blocks to use as the default initial state for an editor session. Each item should be an array containing block name and optional attributes.

So whereever you have the register_post_type(), you could do:

register_post_type(
  'document',
  array(
    …,
    'template' => array(
      array(
        'core/pattern',
        array(
          'slug' => 'theme-name/document-block-pattern',
        ),
      ),
    ),
  )
);

Or if you want to add the template in some package that is decoupled from the code that calls register_post_type(), you can use the register_{$post_type}_post_type_args hook:

function function_name( $args ) {
  $args['template'] = array(
    array(
      'core/pattern',
      array(
        'slug' => 'theme-name/document-block-pattern',
      ),
    ),
  );

  return $args;
}
add_filter( 'register_document_post_type_args', 'function_name' );

tech