I use a block filter to add classes to core and custom blocks. It doesn't work with dynamic blocks though. I tested with my custom block, and then tried with the core latest posts block and it didn't work either. Is it not possible to use block filters to add classes to dynamic blocks?

I'm using the blocks.getSaveContent.extraProps filter, which adds a class to the block on the frontend. My php template for the dynamic block uses this as the outer wrapper, which pulls in alignment and color classes, just not block filter classes:

<div <?php echo wp_kses_data( get_block_wrapper_attributes() ); ?>> inner block stuff</div>


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.