# Setting the default HTML editor in WordPress

> Make WordPress open the HTML (Text) editor by default instead of the Visual editor with a short code snippet.

Source: https://helpcenter.ruachost.com/wordpress/guides/setting-the-default-html-editor-in-wordpress/

By default, WordPress uses the **Visual (WYSIWYG) editor** for writing posts and pages. If you prefer working directly with HTML code, you can configure WordPress to open the **HTML editor** by default. On **ruachost.com**, this can be done by adding a short code snippet to your theme’s configuration.

## Why Change the Default Editor?

- Developers and advanced users may prefer editing raw HTML.
- Provides more control over formatting and structure.
- Avoids conflicts with the Visual editor’s auto‑formatting.

## Steps to Set HTML Editor as Default

1. **Log in to WordPress** with an administrator account.
2. In the dashboard, go to **Appearance → Theme Editor**.
3. From the right‑hand column, select the file named **functions.php**.
4. Scroll to the bottom of the file and add the following code:

   ```
   add_filter( 'wp_default_editor', function() {
       return 'html';
   });
   ```
5. Click **Update File** to save changes.

✅ WordPress will now open the HTML editor by default when creating or editing posts.

## Important Notes

- Always **back up your theme files** before making changes.
- Consider creating a **child theme** to avoid losing customizations during theme updates.
- If you switch themes, you’ll need to re‑apply this code to the new theme’s `functions.php`.
