You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow filtering available templates for a specific post #83120
Plugins need a way to customize the templates available in the post editor for a specific post. A template’s relevance can depend on the post being edited, rather than only its post type.
Gutenberg already applies post-specific restrictions through hardcoded logic in useAllowSwitchingTemplates: template switching is disabled for the designated posts page and for the designated homepage when a front-page template exists.
However, plugins have no equivalent public extension point to filter the available templates for an individual post. For example, WooCommerce needs to restrict the template choices for its configured Shop page without affecting other pages. This is the current behavior:
CleanShot.2026-09-18.at.10.24.02.mp4
Classic themes already support filtering the available templates with theme_{$post_type}_templates. The filter receives the post being edited, allowing plugins and themes to adjust template choices for an individual post rather than applying the same list to every post of that type.
Proposal
Pass the edited post’s slug and post_type from the templates REST endpoint to the existing get_block_templates filter, allowing plugins and themes to customize template choices for a specific post.
The editor should use the returned list for template resolution, previews, and controls. It should keep the assigned template when it appears in the list; otherwise, it should use the first returned template. An empty list falls back to the template hierarchy. Returning a single template makes it the effective template and disables switching, without automatically changing the saved assignment.
Activity