Last active
October 12, 2022 13:41
-
-
Save odil-io/fddf4e68572b442d37265894fa044a2c to your computer and use it in GitHub Desktop.
Gutenberg: Prefix The Content with specified Blocks.
This file contains hidden or 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 | |
/** | |
* Prefix the content of Post Type Page with a set of Blocks. | |
* @see https://wordpress.stackexchange.com/a/323469/218062 | |
*/ | |
function prefix_the_content_with_blocks( $args, $post_type ) { | |
if ( 'page' === $post_type ) { | |
$args['template'] = array( | |
array( | |
'core/group', | |
array( | |
'style' => array( | |
'color' => array( | |
'background' => '#eee', | |
), | |
), | |
), | |
array( | |
array( | |
'yoast-seo/breadcrumbs', | |
), | |
array( | |
'core/heading', | |
array( | |
'placeholder' => __( 'Add an page title', 'textdomain' ), | |
), | |
), | |
), | |
), | |
); | |
} | |
return $args; | |
} | |
add_filter( 'register_post_type_args', 'prefix_the_content_with_blocks', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment