Skip to content
JS Filters

lzb.editor.BlockEdit.attributesForRender

Filters the attributes sent to the server when the editor renders a block preview.

By default the list holds the values of the registered controls plus a few reserved attributes. Use this filter to add an attribute your own code stores on the block but that is not registered as a control, so the preview can render with it.

Attributes

NameTypeDescription
attsForRenderObjectattributes about to be sent for rendering
dataObjectattributes, meta, lazyBlockData, props

data.attributes holds every attribute on the block, including the ones left out of attsForRender.

Usage

JS
wp.hooks.addFilter(
  "lzb.editor.BlockEdit.attributesForRender",
  "my.custom.namespace",
  function (attsForRender, data) {
    if (data.lazyBlockData.slug !== "lazyblock/my-block") {
      return attsForRender;
    }
 
    return {
      ...attsForRender,
      myCustomAttribute: data.attributes.myCustomAttribute,
    };
  }
);

This affects the editor preview only. On the front end the block renders through PHP, where lzb/block_render/attributes does the same job.

Was this article helpful?

Copyright © 2026 Lazy Blocks.