Last active
July 1, 2024 14:01
-
-
Save bacoords/4711fc205898e701eaba36137d71d476 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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