Skip to content

Instantly share code, notes, and snippets.

@joshuafredrickson
Last active October 9, 2020 20:58
Show Gist options
  • Save joshuafredrickson/5df0ddc6a91a67cd9a89939f5323852f to your computer and use it in GitHub Desktop.
Save joshuafredrickson/5df0ddc6a91a67cd9a89939f5323852f to your computer and use it in GitHub Desktop.
WordPress Block Editor: Define a block template that includes a reusable block
<?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