#46261 closed defect (bug) (fixed)
Args for register_post_type() missing blocks $template.
| Reported by: | milana_cap | Owned by: | noisysocks |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.6 |
| Component: | Editor | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: | docs |
Description
Blocks template is added through register_post_type() or register_post_type_args hook but it is not documented.
Attachments (4)
Change History (18)
#3
@
6 years ago
- Resolution fixed
- Status closed → reopened
This change doesn't seem to cover it. The register_post_type function simply stores the args in a WP_Post_Type object. That object has no property or method for a 'template'.
Listing a 'template' argument on this function doesn't document it sufficiently.
#4
@
6 years ago
- Keywords needs-patch added; has-patch removed
I agree, this doesn't help much. What can be done to improve the docs for this parameter?
#5
@
6 years ago
The check for the template property is being performed in wp-admin/edit-form-blocks.php.
if ( ! empty( $post_type_object->template ) ) {
$editor_settings['template'] = $post_type_object->template;
$editor_settings['templateLock'] = ! empty( $post_type_object->template_lock ) ? $post_type_object->template_lock : false;
}
I think we should add the template property to the WP_Post_Type class. Then that would clear up the confusion that @joyously pointed out. Happy to do this if this is agreed upon...
This ticket was mentioned in Slack in #core by metalandcoffee. View the logs.
6 years ago
#8
@
6 years ago
- Owner set to
- Status reopened → reviewing
Thanks for the revised patch @metalandcoffee. It applies cleanly and everything still works when I set template on a post type locally.
Two suggestions:
- Could you please also document the related
template_lockargument and add atemplate_lockproperty toWP_Post_Type?
- Let's add a link to the relevant block editor documentation: https://developer.wordpress.org/block-editor/developers/block-api/block-templates/
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
In 49041: