Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobdubail/789c70e7799c8d2b53032930d8538ac3 to your computer and use it in GitHub Desktop.
Save jacobdubail/789c70e7799c8d2b53032930d8538ac3 to your computer and use it in GitHub Desktop.
Block Template for a Page Template in Gutenberg
<?php
function pls_maybe_add_template() {
if ( ! is_admin() || ! isset( $_GET['post'] ) || 'template-bridge.php' !== get_page_template_slug($_GET['post']) ) {
// This is not the post/page we want to limit things to.
return false;
}
$post_type_object = get_post_type_object( 'page' );
$post_type_object->template = array(
array( 'core/heading', array(
'placeholder' => 'Add Description...',
) ),
);
$post_type_object->template_lock = 'all';
}
add_action( 'init', 'pls_maybe_add_template' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment