#46261 closed defect (bug) (fixed)
Args for register_post_type() missing blocks $template.
Reported by: | milana_cap | Owned by: | noisysocks |
---|---|---|---|
Milestone: | 5.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | has-patch |
Focuses: | docs | Cc: |
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)
#2
@
4 years ago
- Milestone changed from Awaiting Review to 5.6
- Resolution set to fixed
- Status changed from new to closed
#3
@
4 years ago
- Resolution fixed deleted
- Status changed from closed to 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
@
4 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
@
4 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.
4 years ago
#8
@
4 years ago
- Owner set to noisysocks
- Status changed from reopened to 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_lock
argument and add atemplate_lock
property 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/
In 49041: