Home / Admin / Blocks on templates
Duplicate Snippet

Embed Snippet on Your Site

Blocks on templates

Setting a specific block on specific templates by default

Code Preview
php
<?php
/**
 * Setting Hero Block on Pages by default.
 *
 */
function awesome_register_page_template() {
	$post_type_object = get_post_type_object( 'page' );
	$post_type_object->template = array(
		array( 'core/pattern', array(
			'slug' => 'frost/hero',
		) ),
	);
}
add_action( 'init', 'awesome_register_page_template' );

Comments

Add a Comment