Bring back classic widgets in WordPress without a plugin
Go back to the classic Widgets screen with two lines of code. The Snipfire snippet uses the same two filters as the official Classic Widgets plugin.
What Classic Widgets does
The official Classic Widgets plugin restores the classic widget screens and stops the block editor managing widgets. The plugin on WordPress.org
What the snippet does the same
- Appearance > Widgets and the Customizer go back to the classic widget screens.
- It uses the same two filters as the plugin, so the result is the same.
- Like the plugin, there is nothing to set up. It works while it is switched on.
What's different
- Nothing in how it works. The only difference is where the switch lives: in your snippets instead of your plugins list.
- Both only matter with classic themes. Block themes don't have a Widgets screen.
When to keep the plugin Keep the plugin if you prefer an official plugin that the WordPress team maintains for you.
The snippet: Use the classic widgets screen
Appearance > Widgets and the Customizer go back to the classic widgets, as with the Classic Widgets plugin.
<?php
add_filter( 'use_widgets_block_editor', '__return_false' );
add_filter( 'gutenberg_use_widgets_block_editor', '__return_false' );
Notes, where it runs and what it was tested with
Switching from the plugin
- Install the snippet in Snipfire (it arrives switched off).
- Deactivate Classic Widgets.
- Switch the snippet on. Snipfire checks the code and test-loads your site first.
- Check the page it affects, then delete the plugin.