apply_filters( 'use_block_editor_for_post', bool $use_block_editor, WP_Post $post )

Filters whether a post is able to be edited in the block editor.


Parameters Parameters

$use_block_editor

(bool) Whether the post can be edited or not.

$post

(WP_Post) The post being checked.


Top ↑

Source Source

File: wp-admin/includes/post.php

View on Trac



Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 2 content
    Contributed by Ulrich
    function prefix_enable_block_editor_for_post( $use_block_editor, $post ) {
    	// Enable Block Editor for post with ID 123.
    	if ( 123 === $post->ID ) {
    		return true;
    	}
    	return $use_block_editor;
    }
    add_filter( 'use_block_editor_for_post', 'prefix_enable_block_editor_for_post', 10, 2 );
    
  2. Skip to note 3 content
    Contributed by kablesh

    Disable Gutenberg for certain post type

    if ( is_admin() ):
        add_filter( 'use_block_editor_for_post', 'wpdocs_disable_block_for_post_type', 10, 2 );
    endif;
    
    function wpdocs_disable_block_for_post_type( $u, $post ) {
        if ( 'post' === $post->post_type ):
            return false;
        endif;
    
        return true;
    }

You must log in before being able to contribute a note or feedback.