This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Have you ever wondered how to tweak the block editor settings in WordPress? Well, let me introduce you to the block_editor_settings filter. This hook allows you to customize the settings passed to the block editor, and it’s pretty straightforward to use. Just add it to your theme’s functions.php file or, better yet, create a custom WordPress Plugin. This way, your customizations remain intact even after theme updates.
At WePlugins, we always recommend creating a custom WordPress Plugin for implementing hooks to ensure you don’t lose your changes during theme updates. Now, let’s dive into some live examples.
Remove DropCap Option
Here’s how you can remove the DropCap option from the settings panel using the block_editor_settings filter.
/** * Remove DropCap option from settings panel. * * @param array $editor_settings Default editor settings. * @return array $editor_settings Filtered block editor settings. */ add_filter( 'block_editor_settings', function( $editor_settings ) { $editor_settings['__experimentalFeatures']['global']['typography']['dropCap'] = false; return $editor_settings; } );
Modify Default Editor Settings
Below is an example of how you can use this hook to modify the default editor settings according to your website requirements.
function weplugins_modify_block_editor_settings_defaults($editor_settings, $post) { // Update the $editor_settings variable according to your website requirements and return this variable. You can modify the $editor_settings variable conditionally too if you want. return $editor_settings; } // add the filter add_filter( "block_editor_settings", "weplugins_modify_block_editor_settings_defaults", 10, 2 );
Remove Hook Callback
If you need to remove a hook callback, here’s how you can do it. Ensure you provide the same callback function name, priority, and number of arguments while removing the hook callback.
remove_filter( "block_editor_settings", "weplugins_modify_block_editor_settings_defaults", 10, 2 );
Contact Us
If you’re having any trouble using this hook or need customization, please don’t hesitate to contact us at WePlugins. We’d be happy to assist you!
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.