Created
June 9, 2022 23:41
-
-
Save khromov/632ccaee4cf9331c03bbda56ab99df41 to your computer and use it in GitHub Desktop.
WordPress Gutenberg - Add a locked template to a post type
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 | |
add_action('init', function() { | |
// For which posts type | |
$post_type_object = get_post_type_object( 'post' ); | |
// Which allowed blocks | |
$post_type_object->template = [ | |
['core/heading', ['level' => '5', 'content' => 'Default value']], | |
['core/paragraph'], | |
['core/image'], | |
]; | |
// Makes it impossible to move posts | |
$post_type_object->template_lock = 'all'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! <3