How can I remove the H1 option from the gutenberg editor

Gutenberg doesn’t give an option to remove specific heading levels from the editor interface. But, I think you can workaround using a bit of custom code (both PHP and some JavaScript). If you’re interested, try this. Add this custom snippet to your theme’s function.php file.

function remove_h1_from_editor() {
    wp_enqueue_script(
        'remove-h1',
        get_template_directory_uri() . '/js/remove-h1.js',
        array('wp-blocks', 'wp-dom-ready', 'wp-edit-post')
    );
}
add_action('enqueue_block_editor_assets', 'remove_h1_from_editor');

Then, create a JavaScript file in your theme (in my code example, it’s located at /js/remove-h1.js) and add the following code:

wp.domReady(() => {
    wp.blocks.unregisterBlockStyle('core/heading', 'h1');
});

I haven’t tested this, but it should work. If it doesn’t work on your theme, try tweaking the code accordingly.

tech