apply_filters( 'allowed_block_types', bool|array $allowed_block_types, object $post )

Filters the allowed block types for the editor, defaulting to true (all block types supported).


Description Description


Parameters Parameters

$allowed_block_types

(bool|array) Array of block type slugs, or boolean to enable/disable all.

$post

(object) The post resource data.


Top ↑

Source Source

File: wp-admin/edit-form-blocks.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 1 content
    Contributed by Nilambar Sharma

    This allows only paragraph block for post.

    
    function wpdocs_allowed_block_types( $allowed_block_types, $post ) {
        if ( $post->post_type !== 'post' ) {
            return $allowed_block_types;
        }
    
        return array( 'core/paragraph' );
    }
    
    add_filter( 'allowed_block_types', 'wpdocs_allowed_block_types', 10, 2 );
    

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