Improved Snippet Disable Gutenberg Block Editor Everywhere
If you’re running a WordPress site and prefer the Classic Editor over the newer Gutenberg Block Editor, or if you’re looking to make your site load faster, this guide is for you.
Gutenberg is WordPress’s modern editor, but it’s not everyone’s cup of tea. Some folks find the Classic Editor simpler, or they want to avoid extra styles that can slow down their site. This article shares a simple code snippet that disables Gutenberg everywhere (including WooCommerce), works smoothly with other plugins, and speeds up your site by removing unnecessary styles.
Why Disable Gutenberg?
Gutenberg is great for some, but you might want to disable it if:
- You love the Classic Editor’s straightforward interface.
- You’re using WooCommerce and prefer the classic setup for product pages.
- You want to make your site faster by removing unused Gutenberg styles.
- You’re worried about conflicts with your theme or plugins.
The code below does all that while being user-friendly and safe to use, even if other plugins are doing similar things.
// Disable Gutenberg Block Editor everywhere (including WooCommerce) and dequeue styles conditionally.
// Safe to use with other plugins/themes to avoid conflicts.
add_filter('use_block_editor_for_post_type', function ($use_block_editor, $post_type) {
// Return false to disable Gutenberg, but only if not already disabled by another plugin
return apply_filters('disable_gutenberg_for_post_type', false, $post_type);
}, 100, 2);
// Disable Gutenberg for widgets (since WP 5.8).
// Check if filter is already disabled to avoid conflicts.
add_filter('use_widgets_block_editor', function ($use_block_editor) {
// Return false to disable widget block editor, but only if not already disabled
return apply_filters('disable_widgets_block_editor', false);
}, 100);
// Conditionally dequeue Gutenberg-related styles on frontend for performance.
// Only dequeue styles on pages without block content to avoid breaking themes/plugins.
add_action('wp_enqueue_scripts', function () {
if (!function_exists('wp_dequeue_style') || is_admin()) {
return; // Skip in admin or if function doesn't exist
}
// Check if the page has block content (e.g., blocks in post content or widgets)
$has_blocks = has_blocks() || is_active_widget(false, false, 'block', true);
// Only dequeue styles if no block content is detected
if (!$has_blocks) {
wp_dequeue_style('wp-block-library');
wp_dequeue_style('wp-block-library-theme');
// Safely dequeue WooCommerce block styles if WooCommerce is active
if (class_exists('WooCommerce')) {
wp_dequeue_style('wc-block-style');
wp_dequeue_style('wc-blocks-style'); // Additional WooCommerce block styles
}
}
}, 100);How It Works
This snippet does three main things, and it’s built to be safe and user-friendly:
- Disables Gutenberg for All Content:
- It turns off the Gutenberg Block Editor for all post types, including posts, pages, and WooCommerce products. You’ll get the Classic Editor everywhere instead.
- It’s designed to play nice with other plugins (like Classic Editor) by checking if Gutenberg is already disabled, so you won’t run into errors or conflicts.
- Restores Classic Widgets:
- Since WordPress 5.8, the widget area uses a block-based editor. This code switches it back to the Classic Widgets interface, which is simpler for many users.
- Like the editor part, it checks for conflicts to avoid issues with other plugins.
- Speeds Up Your Site:
- Gutenberg loads extra styles (CSS files) on your site’s frontend, which can slow things down. This code removes those styles, but only on pages that don’t use Gutenberg blocks.
- It checks if a page has block content (like reusable blocks or widgets) before removing styles, so your site won’t break if some parts still use blocks.
- If you use WooCommerce, it safely removes WooCommerce block styles too, but only if WooCommerce is active on your site.
What to Expect
Once you add this code:
- Editing: You’ll see the Classic Editor when editing posts, pages, or WooCommerce products. The block editor will be gone, making content creation simpler if you prefer the old-school way.
- Widgets: The widget area (Appearance > Widgets) will use the Classic Widgets interface, which is easier for managing sidebars and footers.
- Performance: Your site should load a bit faster because unnecessary Gutenberg and WooCommerce block styles won’t load on pages that don’t need them. This is especially helpful for speeding up product pages or blog posts.
- Compatibility: The code is designed to avoid breaking your theme or plugins. It checks for block content before removing styles, so your site’s design should stay intact. It also works alongside plugins like Classic Editor without causing errors.
- WooCommerce: If you use WooCommerce, product editing will use the Classic Editor, and block-related styles won’t load unless needed, keeping your shop pages fast and clean.
Tips for Success
- Test Everything: After adding the code, check your site’s key pages (homepage, posts, products, etc.) to make sure nothing looks broken. If you notice styling issues, there might be a block somewhere that needs those styles—let me know, and I can help tweak the code!
- Backup First: Always back up your site before editing code. If something goes wrong, you can restore it easily.
- WooCommerce Users: If you don’t use WooCommerce, the code still works perfectly—it just skips the WooCommerce-specific parts.
- Plugins: If you’re already using a plugin like Classic Editor, this code won’t conflict with it. You might not even need the plugin anymore, but test both ways to see what works best.
- Updates: This code works with WordPress 5.8 and later. If you’re using an older version, let me know, and I can adjust it.
Wrapping Up
This simple code snippet is a powerful way to take control of your WordPress site. It disables Gutenberg everywhere, brings back the Classic Editor and Widgets, and speeds up your site by removing unnecessary styles, all without causing headaches from theme or plugin conflicts.
Whether you’re running a blog, a WooCommerce store, or a custom site, this solution is user-friendly and effective.
Written by Milan on 1st July 2025

