I've restricted a number of the default core Gutenberg blocks as many are unnecessary for my clients and will just add to the confusion of having the new editor.

The result of this is some core categories just have a single block inside them e.g. "formatting" only has a table.

Is it possible to edit/remove core categories and move blocks under a single category??

Limiting my blocks;

add_filter( 'allowed_block_types', 'res_allowed_block_types' );
function res_allowed_block_types( $allowed_blocks ) {
    return array(
        'core/image',
        'core/paragraph',
        'core/heading',
        'core/list',
        'core/quote',
        'core/cover-image',
        'core/file',
        'core/video',
        'core/table',
        'core/separator',
    );
}

Although I'm unsure on how to achieve this in php, within javascript you can change the category by hooking into the blocks.registerBlockType hook.

Here is a small example how it would work, although I'd recommend using lodash to deepClone the settings object to keep everything immutable.

const rearrangeBlockCategories = {
  'core/table': 'common',
};

wp.hooks.addFilter('blocks.registerBlockType', '[namespace]', (settings, name) => {
  if (rearrangeBlockCategories[name]) {
    settings.category = rearrangeBlockCategories[name];  
  }

  return settings;

});
New contributor
jrmd is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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