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 block categories and move all 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',
);
}
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 block categories and move all 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',
);
}
Share
Improve this question
edited May 6, 2019 at 15:29
Christine Cooper♦
8,8977 gold badges60 silver badges93 bronze badges
asked Dec 7, 2018 at 10:28
SamXronnSamXronn
1951 gold badge3 silver badges18 bronze badges
1 Answer
Reset to default 4Although 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;
});