Support

Account

Home Forums Gutenberg get rid of “wp-block-acf-” prefix?

Solved

get rid of “wp-block-acf-” prefix?

  • I use get_block_wrapper_attributes() and apply it only to the frontend to get the same DOM structure on the backend and the frontend. That’s nice and working, but my original class name gets always prefixed with “wp-block-acf-” 🙁

    Is there a way to get rid of the prefix in backend and frontend? Or alternatively put the original class name additionally to the block attributes?

  • Found a solution. There is a filter to allow an alternative class name:

    const setBlockCustomClassName = (className, blockName) => {
    	if (blockName === 'acf/my-custom-block') {
    	   return className + ' my-custom-block';
    	}
    	return className;
    };
    
    wp.hooks.addFilter(
    	'blocks.getBlockDefaultClassName',
    	'my-plugin/my-custom-block',
    	setBlockCustomClassName
    );
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.