Forum Replies Created

Viewing 1 replies (of 1 total)
  • The reason is in the block metadata options. Some default blocks have an __experimentalLayout property. This allows you to generate a layout with different positions of block elements. For example, a Group block can become a row or a column. The position of images in the gallery can be vertical or horizontal. When you change these settings in the blocks in the editor (in the block menu on the right) wordpress adds these damn classes and styles with unique names wp-container-* or wp-block-gallery-* to do on the frontend just like you set up the blocks in the editor. Why such a strange implementation was made, I do not understand.
    But, if you will disable wp_render_layout_support_flag filter (by the way, I removed this – use remove_filter( 'render_block', 'wp_render_layout_support_flag', 10, 2 );), then you will have a mismatch – in the admin panel in the editor there will be horizontal blocking of the blocks in the group (if you set it up like that) and in the front will be vertical – the styles won’t work, you delete them.

    Therefore, the best solution would be to completely disable __experimentalLayout

    
    add_filter( 'block_type_metadata', 'my_remove_experimental_layout', 10, 1 );
    function my_remove_experimental_layout( $metadata ) {
        if ( !empty($metadata['supports']['__experimentalLayout'])) {
            $metadata['supports']['__experimentalLayout'] = false;
        }
        return $metadata;
    }
    

    It completely removes core blocks option to show it in row. But im not sure how it will affect another things…

    I would advise you to use less default blocks, make custom ones, turn off core blocks, leave only the main ones – paragraph, heading, picture, etc.

Viewing 1 replies (of 1 total)