WordPress Classic Editor Defaulting to Text Mode

After updating our servers to use PHP 8, I've recently began encountering an issue where the WordPress Classic Editor defaults to text mode instead of visual mode, which I prefer. After some research, I've found a solution to force the editor to default to visual mode. So, if you're facing the same problem, feel free to follow my simple solution below.

WordPress Classic Editor Defaults to Text Mode

Fixing WordPress Classic Editor Defaulting to Text Mode

To force the WordPress Classic Editor to use visual mode when editing posts, you can add a small piece of code to your theme's functions.php file. To do this, simply follow these steps:

  1. Log in to your WordPress dashboard.
  2. In the left hand menu, navigate to Appearance > Theme Editor.
  3. In the right hand column, you will see a list of theme files. Look for the functions.php file and click on it. This will open the file in the backend editor.
    • Scroll to the bottom of the functions file and add the following code snippet:
      add_filter( 'wp_default_editor', function() {return "tinymce";} );

      Note: This code uses the add_filter function to change the default editor mode to Visual (TinyMCE).

  4. After adding the code, click the Update File button to save your changes.
  5. Now to verify the fix worked, go to any post or page and click Edit. The editor should now default to visual mode instead of text mode.

This should prevent the WordPress classic editor defaulting to text mode when editing posts. But you can still choose to use the text editor to make your html and code changes without affecting this. I hope you found this post helpful... happy blogging!