0

I would like to be able to change the core/heading block label that is shown here, what is the best way to do so?

enter image description here

1 Answer 1

3

That is the block title and you can use the blocks.registerBlockType filter in the block editor to change the block title and other settings as well.

So for example, this would change the title to "My Heading":

function changeHeadingBlockTitle( settings, name ) {
    if ( name !== 'core/heading' ) {
        return settings;
    }

    return lodash.assign( {}, settings, {
        title: 'My Heading',
    } );
}

wp.hooks.addFilter(
    'blocks.registerBlockType',
    'my-plugin/foo',
    changeHeadingBlockTitle
);
1
  • 1
    Thank you very much
    – matthew
    Aug 25, 2020 at 2:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.