use_block_editor_for_post_type( string $post_type ): bool
Returns whether a post type is compatible with the block editor.
Contents
Description
The block editor depends on the REST API, and if the post type is not shown in the REST API, then it won’t work with the block editor.
Parameters
-
$post_type
string Required -
The post type.
Return
bool Whether the post type can be edited with the block editor.
Source
File: wp-includes/post.php
.
View all references
function use_block_editor_for_post_type( $post_type ) {
if ( ! post_type_exists( $post_type ) ) {
return false;
}
if ( ! post_type_supports( $post_type, 'editor' ) ) {
return false;
}
$post_type_object = get_post_type_object( $post_type );
if ( $post_type_object && ! $post_type_object->show_in_rest ) {
return false;
}
/**
* Filters whether a post is able to be edited in the block editor.
*
* @since 5.0.0
*
* @param bool $use_block_editor Whether the post type can be edited or not. Default true.
* @param string $post_type The post type being checked.
*/
return apply_filters( 'use_block_editor_for_post_type', true, $post_type );
}
Hooks
-
apply_filters( 'use_block_editor_for_post_type',
bool $use_block_editor ,string $post_type ) -
Filters whether a post is able to be edited in the block editor.
Changelog
Version | Description |
---|---|
6.1.0 | Moved to wp-includes from wp-admin. |
5.0.0 | Introduced. |
User Contributed Notes
-
Skip to note 1 content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note