Created
April 13, 2018 18:04
-
-
Save zgordon/93377d7ee61fbdbb50bd817c61ffc62b to your computer and use it in GitHub Desktop.
Example of how to set default blocks for a post in Gutenberg with block templates.
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 wpvipblocks_templates( $args, $post_type ) { | |
if ( $post_type == 'post' ) { | |
$args['template_lock'] = true; | |
$args['template'] = [ | |
[ | |
'core/heading', [ | |
'placeholder' => 'Add heading here.', | |
] | |
], | |
[ | |
'core/image', [ | |
'align' => 'right', | |
] | |
], | |
[ | |
'core/paragraph', [ | |
'align' => 'left', | |
'placeholder' => 'Add your description here.', | |
] | |
] | |
]; | |
} | |
return $args; | |
} | |
add_filter( 'register_post_type_args', 'wpvipblocks_templates', 20, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment