Closed
Description
openedon Dec 6, 2017
Although blocks may in many cases replace traditional page templates, there are still a number of cases where different templates are needed
Automatically adding blocks on registering a CPT works well, this could be extended to page templates.
Possible Solution
As page templates are automatically included by WordPress rather than through an action (as with CPTs), this could potentially be controlled by the header comments that already dictate the template name.
<?php
/*
Template Name: Full-width layout
Template Post Type: post, page, event
Allowed Blocks: core/image, core/paragraph, core/quote
Initial Blocks: array(
array( 'core/image' ),
array( 'core/paragraph', array(
'placeholder' => 'Add a book description',
) ),
array( 'core/quote' )
Template Lock: all
*/
// Page code here...
Alternatively, it may be preferable to keep the initial blocks as an action instead, with a new function like the below:
register_template_blocks( $page_template, $args = array(
'template' => array(
array( 'core/image' ),
array( 'core/paragraph', array(
'placeholder' => 'Add a book description',
) ),
array( 'core/quote' ),
),
'template_lock' => 'all'
)
);
Todos
- Implementation
- Tests
- Documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment