Save custom css class (and data) to core/columns block

I wish to add/change class for this div:

<div class=”wp-block-columns has-2-columns”>

There is no possibly to use “wp.blocks.registerBlockStyle” because it doesn’t work for core/columns blocks (“The editor has encountered an unexpected error.”). So I did it by JS (jQuery in fact), using

.addClass(‘my-custom-class’+styleChoosenByUser)

It works – class is added to div in back-office. But of course after refresh F5 class disappear.

So – is it possible to add class to block dynamically? And is it possible to add data to some div?

If not, is it possible to add class dynamically to Advanced “Additional CSS Class” input?

Read more here:: Save custom css class (and data) to core/columns block

Leave a Reply

Your email address will not be published. Required fields are marked *