Skip to content
PHP Filters

lzb/block_render/template_exists

Filters block template path for https://www.lazyblocks.com/docs/blocks-code/theme-template/.

Used in combination with https://www.lazyblocks.com/docs/php-filters/lzb-block_render-include_template/.

Attributes

NameTypeDescription
$templateStringblock template path
$attributesArrayblock attributes
$blockArrayblock data
$contextStringrendering context [editor, frontend]

Additional Filters

NameDescription
lazyblock/BLOCK_SLUG/frontend_template_existsspecific block in the frontend only
lazyblock/BLOCK_SLUG/editor_template_existsspecific block in the editor only
lazyblock/BLOCK_SLUG/template_existsspecific block only

Usage

PHP
function my_lzb_block_render_template_exists( $template, $attributes, $block, $context ) {
  // Custom template for all blocks
  return '/YOUR_CUSTOM/BLOCK/PATH.php';
}
 
add_filter( 'lzb/block_render/template_exists', 'my_lzb_block_render_template_exists', 10, 4 );
PHP
function my_lzb_block_render_template_exists( $template, $attributes, $block, $context ) {
  // Custom output for all blocks
  return '/YOUR_CUSTOM/BLOCK/PATH.php';
}
 
add_filter( 'lzb/block_render/template_exists', 'my_lzb_block_render_template_exists', 10, 4 );

Was this article helpful?