Skip to content
PHP Filters

lzb/block_render/attributes

Filters block attribute before render block output.

Attributes

NameTypeDescription
$attributesArrayblock attributes
$contentStringblock content
$blockArrayblock data
$render_locationStringrendering location [editor, frontend]
$contextArrayblock context data provided by parent blocks

Additional Filters

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

Usage

PHP
function my_lzb_block_render_attributes( $attributes, $content, $block, $render_location, $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, 5 );
PHP
function my_lzb_block_render_attributes( $attributes, $content, $block, $render_location, $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, 5 );

Was this article helpful?