Blog / WordPress/ How to Disable the Gutenberg Editor in WordPress with Code

How to Disable the Gutenberg Editor in WordPress with Code

WordPress使用代码禁用古腾堡编辑器

How to Disable the Gutenberg Editor

While some users prefer to optimize the Gutenberg (block) editor, others may wish to disable it entirely and revert to the classic editor. This can be achieved without a plugin using a simple code snippet.

Disable Code

Add the following line to the end of your active theme's functions.php file:

add_filter('use_block_editor_for_post', '__return_false');

Code Explanation:

  • add_filter: A WordPress function to hook a callback into a filter.
  • use_block_editor_for_post: The filter hook that controls whether the block editor is used for a post.
  • __return_false: A WordPress helper function that returns false. Using it here disables the block editor for all posts.

Important Notes

  • This method globally disables the Gutenberg editor for all posts and pages, restoring the classic editor.
  • Always back up your functions.php file before making changes.
  • If using a child theme, add the code there. If not, consider creating a child theme to prevent code loss during parent theme updates.
  • After adding the code, the classic editor will appear when creating or editing posts.

Post a Comment

Your email will not be published. Required fields are marked with *.