Independent Editorial DeskWordPress Releases, Builds, and Operations
Back to Archive
Implementation Notes

WordPress allowed_block_types_all Example: Restrict Editor Blocks Safely

Use allowed_block_types_all to narrow the block inserter for a specific post type without breaking unrelated editor contexts.

Published

April 30, 2026

Reading Time

2 min read

Updated

April 30, 2026

Abstract block gate representing restricted editor block allowlists in WordPress.
Build PatternImplementation Notes

Implementation Notes

Extension points, code paths, and implementation choices that should survive contact with production.

Best For

WordPress developers, agencies, and technical teams building custom plugin or theme functionality with cleaner operational defaults.

Primary Topics

Implementation Notes

Editorial Focus

Build Pattern: Extension points, code paths, and implementation choices that should survive contact with production. Updated on April 30, 2026.

Full Report

Last reviewed: April 30, 2026

The block editor becomes noisy fast when every post type exposes every block, especially on sites with strict editorial workflows. The allowed_block_types_all filter is the clean way to narrow the inserter for a specific editing context without unregistering blocks globally.

This guide shows how to restrict allowed blocks for one post type while leaving the rest of the editor experience untouched.

Scope the restriction to a real editor context

<?php
add_filter( 'allowed_block_types_all', 'vulnwp_limit_post_blocks', 10, 2 );

function vulnwp_limit_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/list',
		'core/image',
		'core/quote',
	);
}

The key here is not the array itself. It is the guard clause that avoids applying the restriction to unrelated editors.

Return the incoming default when you are not restricting

The filter accepts either true or an array of block slugs. If a request is outside the targeted post type or editor state, return the incoming value instead of forcing a global rule.

Be careful around site editor and template contexts

The WordPress Developer Blog explicitly warns that aggressive block restrictions can break template editing flows. Production code should scope the filter to content types that truly need editorial constraints.

Keep the allowlist short and intentional

If authors only need five block types for a press-release post type, give them five. A vague half-restriction usually creates the worst of both worlds: editorial confusion without real consistency.

Production checklist

  • Check the editor context before returning a restricted array.
  • Limit blocks only for post types with a defined editorial model.
  • Return the original value for unrelated editors.
  • Test the Site Editor and template editing after rollout.
  • Document the exact allowlist for editorial teams.
  • Review plugin-provided block slugs before finalizing the rule set.

Common mistakes

  • Applying one allowlist everywhere. Template editors and post editors do not always need the same rules.
  • Forgetting editor context checks. That is how block restrictions leak into the wrong screens.
  • Returning a hardcoded boolean for all cases. That overrides more than intended.
  • Allowlisting blocks by guesswork. Use real registered slugs.
  • Restricting before the editorial workflow is defined. Rules should follow content operations, not precede them.

Related reading

If the goal is visual consistency rather than block removal, use the register_block_style guide. If the block itself is custom and controlled through metadata, continue with the block.json article.

References and further reading

Popular Guides

Popular WordPress guides to read next.

These articles connect recurring production concerns: implementation details, updates, troubleshooting, recovery paths, and operational cleanup.

Continue Reading

More from the archive.

Diagnostic dashboard scene representing a WordPress Site Health review before major updates.
01Build Pattern
Implementation Notes

Build Pattern

Extension points, code paths, and implementation choices that should survive contact with production.

May 21, 2026 · 3 min read

WordPress Site Health Check Before Major Updates: What to Review First

A pre-update WordPress Site Health checklist covering loopbacks, connectivity, debug settings, and environment readiness.

Structured data and route review scene representing permalink validation after a WordPress migration.
02Build Pattern
Implementation Notes

Build Pattern

Extension points, code paths, and implementation choices that should survive contact with production.

May 21, 2026 · 3 min read

WordPress Permalink Checklist After Migration: Catch URL Problems Early

A post-migration WordPress permalink checklist for checking rewrite rules, post URLs, archives, and redirect noise.

Technical media workspace representing image preparation and optimization before upload to WordPress.
03Build Pattern
Implementation Notes

Build Pattern

Extension points, code paths, and implementation choices that should survive contact with production.

May 21, 2026 · 3 min read

WordPress Image Optimization Checklist: What to Fix Before Upload

A practical WordPress image optimization checklist covering dimensions, compression, formats, and Media settings before upload.