Home » Hooks » use_block_editor_for_post

The use_block_editor_for_post hook is a filter that determines whether or not to use the block editor for a specific post. Introduced in WordPress 5.0, the block editor (also known as Gutenberg) is a new way of creating content in WordPress that allows users to build pages and posts using blocks that can be customized individually.

This hook allows developers to override the default behavior of the block editor and specify whether or not a particular post should use the block editor. By default, the block editor is enabled for all posts, but this can be changed on a per-post basis using this hook.

To use this hook, you would add a filter to your functions.php file that checks if the block editor should be used for a specific post. If the filter returns true, the block editor will be used, and if it returns false, the classic editor will be used instead.

Here is an example usage code:

function my_custom_use_block_editor_for_post( $should_use_block_editor, $post ) {
    if ( $post->ID === 123 ) { // Change 123 to the ID of your post
        return false; // Disable the block editor for this post

    return $should_use_block_editor; // Use the default behavior for all other posts

add_filter( 'use_block_editor_for_post', 'my_custom_use_block_editor_for_post', 10, 2 );

In this example, we’re checking if the post ID is equal to 123 and, if so, returning false to disable the block editor for that post. For all other posts, we’re returning the default behavior using the $should_use_block_editor parameter.

Learn More on

WordPress snippets using the use_block_editor_for_post hook

Register an account to save your snippets or go Pro to get more features.