Add ability to set default rendering mode per post type #62302
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Related Issue & PR:
block_editor_settings_all
hook in PHP to allow customizing it #61844This PR adds a filterable
rendering_mode
property to theWP_Post_Type
object allowing users to define the default rendering mode for the editor for that post type.The
rendering_mode
property can be added to the arguments when registering the post type viaregister_post_type()
and can be overwritten using the available filters:{$post_type}_default_rendering_mode
: To target an individual specific post type.post_type_default_rendering_mode
: To target all (or multiple) post types.Why?
Currently there is no way to set the default rendering mode of the block editor. You can select the mode while in the block editor, but upon refreshing that mode is reset back to the default
post-only
. With this update developers have more control over the editing experience and provides a means of setting the default view for the block editor.How?
The linked PR has a discussion that mentions this setting should be applied at the post type level, allowing for a difference editing mode per post type. This PR applies the
rendering_mode
property to theWP_Post_Type
object itself and provides multiple ways of overriding or setting the default for a custom (or core) post type.Testing Instructions
post
post type and observe the default editor UI.functions.php
file (or similar) use one of the available filters to set therendering_mode
property totemplate-lock
:post
editor and confirm you are now seeing the Template UI instead of the default Post UI.page
post and confirm thepage
editor also loads with the Template UI.functions.php
to target only thepage
post type:page
editor and confirm it still renders the Template UI.post
editor and confirm it now renders the default Post UI.functions.php
to set the rendering mode for thepost
andpage
post types, but no others:register_post_type
and set therendering_mode
parameter totemplate-lock
:rendering_mode
argument from your post type registration & confirm the editor now loads with the default Post UI.