Skip to content

Instantly share code, notes, and snippets.

@odil-io
Last active October 12, 2022 13:41
Show Gist options
  • Save odil-io/fddf4e68572b442d37265894fa044a2c to your computer and use it in GitHub Desktop.
Save odil-io/fddf4e68572b442d37265894fa044a2c to your computer and use it in GitHub Desktop.
Gutenberg: Prefix The Content with specified Blocks.
<?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