---
title: "lzb/block_render/attributes"
description: "PHP filter `lzb/block_render/attributes` of the Lazy Blocks WordPress plugin."
url: "https://www.lazyblocks.com/docs/php-filters/lzb-block_render-attributes/"
lastUpdated: 2026-09-09
source: "php-filters/lzb-block_render-attributes.mdx"
---
# lzb/block_render/attributes

Supplies a value the template needs but no control stores, such as the current post's terms or a price pulled from another table.

It is the first filter in the render pipeline. Every control value has already been resolved and passed through [lzb/control_value](https://www.lazyblocks.com/docs/php-filters/lzb-control_value/) by this point, and nothing has been rendered yet, so an attribute added here is visible to the PHP template, to the Handlebars template and to the theme template file alike.

## Attributes

| Name               | Type               | Description                                                                                                                  |
| ------------------ | ------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
| `$attributes`      | **Array**          | control values keyed by control name, plus the reserved `lazyblock`, `className`, `anchor`, `blockId` and `blockUniqueClass` |
| `$content`         | **String \| null** | inner blocks markup, `null` when the block has none                                                                          |
| `$block`           | **Array**          | block data, the same array [lzb/block_data](https://www.lazyblocks.com/docs/php-filters/lzb-block_data/) returns                                       |
| `$render_location` | **String**         | `editor` or `frontend`                                                                                                       |
| `$context`         | **Array \| null**  | block context from parent blocks                                                                                             |

`$context` is `null` for an ordinary render. It only carries values when the block declares `uses_context` through the Pro Relationships feature, or when the render comes from the editor preview REST route.

## Additional Filters

| Name                                       | Arguments                                                   | Description                         |
| ------------------------------------------ | ----------------------------------------------------------- | ----------------------------------- |
| `lazyblock/BLOCK_SLUG/frontend_attributes` | `$attributes, $content, $block, $context`                   | specific block in the frontend only |
| `lazyblock/BLOCK_SLUG/editor_attributes`   | `$attributes, $content, $block, $context`                   | specific block in the editor only   |
| `lazyblock/BLOCK_SLUG/attributes`          | `$attributes, $content, $block, $render_location, $context` | specific block only                 |

The per-location variants take four arguments, not five. They already know the render location from their own name, so `$context` moves into the fourth position.

## Usage

```php title="PHP"
function my_lzb_block_render_attributes( $attributes, $content, $block, $render_location, $context ) {
  // Give the recipe block the current post's cuisine terms, which no
  // control stores.
  if ( 'lazyblock/recipe' !== $block['slug'] ) {
    return $attributes;
  }

  $attributes['cuisines'] = wp_get_post_terms( get_the_ID(), 'cuisine', array( 'fields' => 'names' ) );

  return $attributes;
}

add_filter( 'lzb/block_render/attributes', 'my_lzb_block_render_attributes', 10, 5 );
```

The return value has to be an array, because the render callback indexes into it straight afterwards. An attribute added here exists only during the render. It is not registered with `register_block_type()`, so the editor never saves it and Gutenberg never validates it. Removing a key that a control declared leaves the template reading an undefined index instead of an empty string.

To change the finished markup rather than its inputs, use [lzb/block_render/output](https://www.lazyblocks.com/docs/php-filters/lzb-block_render-output/).

## Documentation Index
> Fetch the complete documentation index at: https://www.lazyblocks.com/llms.txt
> Fetch every page in a single file at: https://www.lazyblocks.com/llms-full.txt
