Skip to content
PHP Filters

lzb/block_render/attributes

Filters block attribute before render block output.

Attributes

NameTypeDescription
$attributesArrayblock attributes
$contentStringblock content
$blockArrayblock data
$contextStringrendering context [editor, frontend]

Additional Filters

NameDescription
lazyblock/BLOCK_SLUG/frontend_attributesspecific block in the frontend only
lazyblock/BLOCK_SLUG/editor_attributesspecific block in the editor only
lazyblock/BLOCK_SLUG/attributesspecific block only

Usage

PHP
function my_lzb_block_render_attributes( $attributes, $content, $block, $context ) {
  // Change value of custom attribute "my-attribute"
  $attributes['my-attribute'] = 'custom attribute value';
 
  return $attributes;
}
 
add_filter( 'lzb/block_render/attributes', 'my_lzb_block_render_attributes', 10, 4 );
PHP
function my_lzb_block_render_attributes( $attributes, $content, $block, $context ) {
  // Change value of custom attribute "my-attribute" for block "lazyblock/my-custom-block"
  $attributes['my-attribute'] = 'custom attribute value';
 
  return $attributes;
}
 
add_filter( 'lazyblock/my-custom-block/attributes', 'my_lzb_block_render_attributes', 10, 4 );

Was this article helpful?