WordPress 6.9: New Built-in Feature to Hide Blocks
WordPress 6.9's new block hiding feature allows easy content visibility management without deletion. Learn usage and how to programmatically disable this capability.
Ability to Hide Blocks in WordPress 6.9
WordPress 6.9 now includes a built-in feature that allows users to hide blocks, providing a straightforward way to manage content visibility without permanent deletion. This new capability streamlines the editing experience by allowing you to temporarily tuck away content.
How to Hide Blocks:
To hide a block, simply select the desired block, click the ellipsis (...) menu, and choose "Hide". Once hidden, blocks are visually removed from the editor interface and completely omitted from the published markup. By default, scripts and styles associated with hidden blocks are also excluded from the rendered page for improved performance. (For more detailed information, consult the WordPress 6.9 Frontend Performance Field Guide.)
How to Unhide Blocks:
To reveal a hidden block, open the List View. Hidden blocks are easily identifiable by a "Hidden" icon displayed next to them. From there, open the ellipsis menu again and select "Show".
For keyboard users, toggling visibility is also possible: use Ctrl + Shift + H on Windows or Linux, or ⌘ + Shift + H on macOS.
Understanding Key Terms:
- Block: The abstract term describing units of markup that form the content or layout of a webpage using the WordPress editor. This concept unifies past approaches like shortcodes, custom HTML, and embed discovery into a consistent API and user experience.
- API (Application Programming Interface): A software intermediary that enables programs to interact and share data in defined ways.
- Capability: Permission to perform one or more types of tasks within WordPress, checked by the
current_user_canfunction. User roles determine specific capabilities. - Core: The essential software required to run WordPress, developed by the Core Development Team.
How to Disable the Hide Option
The block hiding feature is implemented as a standard Block API support flag. Consequently, enabling or disabling this capability aligns with existing block support mechanisms. This support is active by default for almost all block types, with the exception of a select list of core blocks.
To selectively disable visibility support for a specific block type, you can use the block_type_metadata() filter. Adjust the block's metadata by updating its supports.visibility flag to false.
Example Code:
function disable_block_visibility_support( $metadata ) {
// Disable visibility support for the core/group block.
if ( isset( $metadata['name'] ) && 'core/group' === $metadata['name'] ) {
$metadata['supports']['visibility'] = false;
}
return $metadata;
}
add_filter( 'block_type_metadata', 'disable_block_visibility_support' );
For more in-depth implementation details and historical context, refer to Gutenberg PR #71203.
Props to @joen for co-authoring this note. Special thanks to @westonruter and @ramonopoly for their review.