Answer the question
In order to leave comments, you need to log in
Gutenberg How to set default css class for blocks?
You need to change the default classes of the gutenberg blocks.
For example, the Video block is displayed like this:
<figure class="wp-block-video"><video controls="" src="..."></video></figure>
<figure class="publication__video wp-block-video"><video controls="" src="..."></video></figure>
Answer the question
In order to leave comments, you need to log in
There are several solutions:
1. HTML patching of the rendered block
The easiest to implement, but far from the most stable option. Define a filter to render your block type, in this case:
add_filter('render_block_core/video', function (string $content, array $block) {
// Здесь вам нужно изменить содержимое переменной $content
// она содержит уже отрендеренный HTML код блока.
return $content;
}, 10, 2);
register_block_type
define your own block and write your own render for it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question