Skip to content
JS Filters

lzb.constructor.general-settings.keywords

Filters the Keywords field of the block builder general settings. Return a falsy value to hide it, which is what a site does when the keywords of a block are owned by code and editing them by hand would only cause drift.

Attributes

NameTypeDescription
elementJSXPanelBody holding the keywords control
settingsDataObjectdata, updateData

settingsData.data is the whole block data, so data.keywords holds the current comma-separated value and data.slug, data.icon, data.category and data.description hold the values behind the other four general settings. settingsData.updateData shallow merges the object you pass it into that block data.

The five general settings render in a fixed order: slug, icon, category, keywords, description. This filter changes what stands in the keywords position, it cannot move the field.

Usage

The builder renders the filtered value as {settingsKeywords || null}, so returning null takes the field off the screen.

JS
wp.hooks.addFilter(
  "lzb.constructor.general-settings.keywords",
  "my.custom.namespace",
  function (element, settingsData) {
    const slug = settingsData.data.slug || "";
 
    if (slug.indexOf("lazyblock/generated-") !== 0) {
      return element;
    }
 
    return null;
  },
);

Hiding the field does not clear the stored value. A block saved earlier keeps the keywords it had and nothing in the builder can change them any more, so code that hides this field has to set keywords elsewhere, for example through lzb/register_block_type_data. Do not call updateData from inside the filter, because it runs during render and dispatching there makes React warn about updating one component while another renders. The other four fields go through lzb.constructor.general-settings.slug, lzb.constructor.general-settings.icon, lzb.constructor.general-settings.category and lzb.constructor.general-settings.description.

Was this article helpful?

Copyright © 2026 Lazy Blocks.