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
Name | Type | Description |
---|---|---|
$template | String | block template path |
$template_name | String | template name |
$attributes | Array | block attributes |
$block | Array | block data |
$render_location | String | rendering location [editor , frontend ] |
$context | Array | block context data provided by parent blocks |
Additional Filters
Name | Description |
---|---|
BLOCK_SLUG/frontend_template_exists | specific block in the frontend only |
BLOCK_SLUG/editor_template_exists | specific block in the editor only |
BLOCK_SLUG/template_exists | specific block only |
Usage
function my_lzb_block_render_template_exists( $template, $template_name, $attributes, $block, $render_location, $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, 6 );
function my_lzb_block_render_template_exists( $template, $template_name, $attributes, $block, $context ) {
// Custom template for specific block
return '/YOUR_CUSTOM/BLOCK/PATH.php';
}
add_filter( 'lazyblock/my-custom-block/template_exists', 'my_lzb_block_render_template_exists', 10, 5 );