How to use filter hook for templates?
briansteeleca opened this issue · comments
I see you can add your own templates with the wpBootstrapBlocks.row.templates filter (https://github.com/liip/bootstrap-blocks-wordpress-plugin#wpbootstrapblocksrowtemplates), but not being versed on block development, I don't understand how to use this filter. Where should this code be added?
It looks like one could modify the templates in row/block.js, but the filter seems like a better option.
You can use this usage example as a starting point to modify the templates: https://github.com/liip/bootstrap-blocks-wordpress-plugin#usage-9
Just place it in a JavaScript file in your theme (eg. bootstrap-block-row-templates.js
) and load the file like this:
function mytheme_enqueue_block_editor_assets() {
// Scripts.
wp_enqueue_script(
'mytheme-editor-js', // Handle.
get_template_directory_uri() . '/path-to-assets/bootstrap-block-row-templates.js',
array('wp-hooks'),
true // Enqueue the script in the footer.
);
}
add_action( 'enqueue_block_editor_assets', 'mytheme_enqueue_block_editor_assets', 10 );
Thanks Jürg, much appreciated!
Glad to help 👍🏻