Skip to content
PHP Filters

lzb/block_render/output

Wraps or rewrites finished block markup, which is what adding a schema script, a lazy-loading attribute or an analytics hook to every block takes.

It is the last filter in the render pipeline. The template has run, <InnerBlocks /> has been replaced with the real inner content, and the useBlockProps tag has already become a real wrapper carrying the block's classes, ID and alignment. What you receive is the exact string WordPress is about to print. Lazy Blocks Pro hooks this at priority 199 to collect styles for the block builder preview, and at priority 200 to cache editor renders for preloading, so a handler at the default priority 10 runs before both.

Attributes

NameTypeDescription
$resultStringfinished block markup
$attributesArraycontrol values, as the template saw them
$render_locationStringeditor or frontend
$blockArrayblock data, the same array lzb/block_data returns
$contextArray | nullblock context from parent blocks
$contentString | nullinner blocks markup before it was substituted

Additional Filters

NameArgumentsDescription
lazyblock/BLOCK_SLUG/frontend_output$result, $attributes, $block, $context, $contentspecific block in the frontend only
lazyblock/BLOCK_SLUG/editor_output$result, $attributes, $block, $context, $contentspecific block in the editor only
lazyblock/BLOCK_SLUG/output$result, $attributes, $render_location, $block, $context, $contentspecific block only

The per-location variants take five arguments, with $render_location left out.

Usage

PHP
function my_lzb_block_render_output( $result, $attributes, $render_location, $block, $context, $content ) {
  // Append FAQ schema to the FAQ block on the front end only.
  if ( 'frontend' !== $render_location || 'lazyblock/faq' !== $block['slug'] ) {
    return $result;
  }
 
  $schema = array(
    '@context'   => 'https://schema.org',
    '@type'      => 'Question',
    'name'       => $attributes['question'],
    'acceptedAnswer' => array(
      '@type' => 'Answer',
      'text'  => wp_strip_all_tags( $attributes['answer'] ),
    ),
  );
 
  return $result . '<script type="application/ld+json">' . wp_json_encode( $schema ) . '</script>';
}
 
add_filter( 'lzb/block_render/output', 'my_lzb_block_render_output', 10, 6 );

Return a string. Returning null makes WordPress print nothing for the block, and returning an array raises a TypeError when the block content is concatenated. Because this runs after the wrapper is built, replacing the whole string throws away the block's generated classes, so keep the outer tag and modify around it.

To change the block's inputs instead of its output, use lzb/block_render/attributes. To replace the render entirely, use lzb/block_render/callback.

Was this article helpful?

Copyright © 2026 Lazy Blocks.