Created
May 21, 2020 20:42
-
-
Save jacobdubail/789c70e7799c8d2b53032930d8538ac3 to your computer and use it in GitHub Desktop.
Block Template for a Page Template in Gutenberg
This file contains 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 | |
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