Last active
October 9, 2020 20:58
-
-
Save joshuafredrickson/5df0ddc6a91a67cd9a89939f5323852f to your computer and use it in GitHub Desktop.
WordPress Block Editor: Define a block template that includes a reusable block
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 | |
/** | |
* Define a block template for a post type that includes a reusable block. | |
* Find the reusable block ID at /wp-admin/edit.php?post_type=wp_block | |
* | |
* @return void | |
*/ | |
add_action('init', function () { | |
$post_type_object = get_post_type_object('page'); // Set the post type | |
$post_type_object->template = [ | |
['core/paragraph'], | |
['core/block', ['ref' => 48170]], // Reusable block ID | |
]; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment