Skip to content
PHP Filters

lzb/get_meta

Changes what get_lzb_meta() hands back to a theme file, which is where a fallback value or a formatted version belongs when the same meta is read from a dozen templates.

It fires on the way out of get_lzb_meta(), after the value has been read from post meta and after lzb/control_value has converted it for its control type. Inside the block editor preview the value comes from the block being previewed rather than from the database, and this filter still runs, so a fallback added here shows up in the preview too.

Attributes

NameTypeDescription
$resultMixedvalue returned by get_lzb_meta()
$nameStringmeta name asked for
$idInt | nullpost ID, null when no ID was passed and there is no global post
$control_dataArray | nullthe control that saves this meta, null when no control does

$control_data is found by walking every block's controls for one whose Save in Meta is on and whose meta name matches. A meta name that no control owns still reaches this filter, with $control_data as null and $result straight from get_post_meta().

Usage

PHP
function my_lzb_get_meta( $result, $name, $id, $control_data ) {
  // Fall back to the site name for the page subtitle, so templates do not
  // each need their own empty check.
  if ( 'page-subtitle' !== $name || ! empty( $result ) ) {
    return $result;
  }
 
  return get_bloginfo( 'name' );
}
 
add_filter( 'lzb/get_meta', 'my_lzb_get_meta', 10, 4 );

Guard on $name, as above. The filter fires for every meta name Lazy Blocks is asked for, so a handler that changes $result unconditionally rewrites unrelated fields. Return the type the control saves. A Repeater's value is an array and a template that iterates it breaks on a string.

To change the value for every use rather than only for get_lzb_meta(), hook lzb/control_value instead. Reading meta from templates is covered in Display custom fields meta.

Was this article helpful?

Copyright © 2026 Lazy Blocks.