Skip to main content
Login Join
Snippet · PHP

Restrict Allowed Block Types for Posts

Shared by Yusuf mudagal · May 3, 2026 · @allowed_block_types_all

36 views
Back to Snippets

Limits the editor block picker for posts to a focused set of common content blocks.

add_filter( 'allowed_block_types_all', 'wpfolks_allowed_post_blocks', 10, 2 );

function wpfolks_allowed_post_blocks( $allowed_blocks, $editor_context ) {
    if ( empty( $editor_context->post ) || 'post' !== $editor_context->post->post_type ) {
        return $allowed_blocks;
    }

    return array( 'core/paragraph', 'core/heading', 'core/image', 'core/list', 'core/quote' );
}
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments