lzb/block_render/allow_inner_blocks_wrapper
Drops the <div> Lazy Blocks puts around inner blocks, which a block whose children have to be direct descendants of a grid or a flex container needs.
The default is true. With the wrapper on, the inner content is placed inside a <div> whose class is taken from a class or className attribute on the <InnerBlocks /> tag in your template, falling back to lazyblock-inner-blocks. With it off, the inner content replaces <InnerBlocks /> exactly where it stands and no element is added. The filter runs on the front end only, so the editor keeps its own wrapper and the two views differ until you account for that in your CSS.
Attributes
| Name | Type | Description |
|---|---|---|
$allow_inner_blocks_wrapper | Boolean | render the wrapper, true by default |
$attributes | Array | control values, as the template saw them |
$context | Array | null | block context from parent blocks |
The block itself is not passed. Read its slug from $attributes['lazyblock']['slug'], or use the per-block variant below.
Additional Filters
| Name | Arguments | Description |
|---|---|---|
lazyblock/BLOCK_SLUG/allow_inner_blocks_wrapper | $allow_inner_blocks_wrapper, $attributes, $context | specific block |
Usage
function my_lzb_allow_inner_blocks_wrapper( $allow, $attributes, $context ) {
// The columns block is a CSS grid, so its children have to be direct
// descendants and the extra div would break the layout.
if ( 'lazyblock/columns' === $attributes['lazyblock']['slug'] ) {
return false;
}
return $allow;
}
add_filter( 'lzb/block_render/allow_inner_blocks_wrapper', 'my_lzb_allow_inner_blocks_wrapper', 10, 3 );// Drop the wrapper for one block, without a callback.
add_filter( 'lazyblock/columns/allow_inner_blocks_wrapper', '__return_false' );The return value is used as a boolean, so anything truthy keeps the wrapper. Turning it off for a block that has no inner content leaves <InnerBlocks /> replaced with an empty string rather than an empty <div>, which changes what a :empty or :first-child selector matches.
See Inner Blocks Wrapper for how the wrapper class is picked up from the template.