Skip to content

Instantly share code, notes, and snippets.

@annelyse
Created April 20, 2023 07:40
Show Gist options
  • Save annelyse/acb7d1ce83bd8b3cb6ed7258bb2a9950 to your computer and use it in GitHub Desktop.
Save annelyse/acb7d1ce83bd8b3cb6ed7258bb2a9950 to your computer and use it in GitHub Desktop.
function gutenberg_examples_dynamic() {
// automatically load dependencies and version
register_block_type( 'custom-e2s/bloc-left', array(
'api_version' => 2,
'render_callback' => function($attributes, $content ) {
$path = locate_template( 'templates/blocks/bloc-left.php' );
if ( file_exists( $path ) ) {
ob_start();
echo get_template_part(
'templates/blocks/bloc-left',
null,
array(
$attributes, $content
)
);
$block = ob_get_contents();
ob_end_clean();
return $block;
}
}
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment