Skip to content

Instantly share code, notes, and snippets.

@bacoords
Last active July 1, 2024 14:01
Show Gist options
  • Save bacoords/4711fc205898e701eaba36137d71d476 to your computer and use it in GitHub Desktop.
Save bacoords/4711fc205898e701eaba36137d71d476 to your computer and use it in GitHub Desktop.
<?php
/**
* Register custom block template
*
* @return void
*/
function prefix_register_block_templates() {
// Theme pattern example:
$page_template = array(
array(
'core/pattern',
array(
'slug' => 'themeslug/some-example-pattern',
),
),
);
// Synced pattern example:
$page_template = array(
array(
'core/block',
array(
'ref' => 6
),
),
);
// Add it to the existing post type:
$post_type_object = get_post_type_object( 'page' );
$post_type_object->template = $page_template;
}
add_action( 'init', 'prefix_register_block_templates' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment