Short answer: To disable WordPress file editor access, add define( 'DISALLOW_FILE_EDIT', true ); to your wp-config.php file, above the comment that reads "That's all, stop editing!". The Theme File Editor and the Plugin File Editor then disappear for every user, administrators included. Your posts, plugins, theme and updates keep working as before. Before you open wp-config.php, take a backup and confirm it restores, because a single typo in that file can stop the whole site from loading.
WordPress version covered: 7.1.2, released September 22, 2026. Last verified: October 2, 2026.
There's a code editor in your admin. Should there be?
It is there by default, and most site owners never asked for it. There are actually two: a Theme File Editor and a Plugin File Editor. Both open the live PHP files that run your site and let anyone with the right permission rewrite them from a browser tab.
Where they sit depends on your theme. In the WordPress 7.1 admin menu code, the locations are:
| Your theme type | Theme File Editor | Plugin File Editor |
|---|---|---|
| Block theme (such as Twenty Twenty-Five) | Tools > Theme File Editor | Tools > Plugin File Editor |
| Classic theme | Appearance > Theme File Editor | Plugins > Plugin File Editor |
If a tutorial told you to look under Appearance and you found nothing, this table is usually why. Block themes move both editors under Tools.
On a single site, the Administrator role can open both editors. On a multisite network, WordPress 7.1 limits them to super admins only. If you are not sure how many people on your site hold the Administrator role, our guide to WordPress user roles and what each one can reach is the place to check first.
Why turning it off is the easiest win
The WordPress Advanced Administration Handbook's Hardening WordPress page (last updated January 7, 2026, read October 2, 2026) says the dashboard editor "is often the first tool an attacker will use if able to login, since it allows code execution." In plain terms: if someone steals an administrator password, the editor lets them paste their own code straight into a file that runs on every page load.
Compare what you give up with what you get:
| With the editor on | With DISALLOW_FILE_EDIT set | |
|---|---|---|
| Edit theme or plugin PHP from the dashboard | Yes | No |
| A stolen admin login can rewrite PHP from the browser | Yes | Not through the editors |
| Install and update plugins and themes from the dashboard | Yes | Yes, unchanged |
| Additional CSS box | Yes | Yes, unchanged |
| Edit files by SFTP or your host's file manager | Yes | Yes, unchanged |
The cost is close to zero for a one-person site. The editor is a tool you should rarely use anyway: WordPress's own Theme File Editor documentation warns that "The editor does not make backup copies," and that if an edit crashes the site, "you cannot use the editor to fix the problem."
That is why this ranks as an easy win. One line, no plugin, no ongoing upkeep, and nothing a normal day of running the site depends on.
Before you start: a backup you have actually tested
This change is small, but it happens inside wp-config.php, the file that holds your database connection details. A missing semicolon or a curly quote pasted from a word processor can turn every page of the site into an error, including the dashboard. So the rule is simple: no backup, no edit.
Run through the five-minute ritual before any risky WordPress edit, then make sure the backup is real. A backup file that has never been opened is a hope, not a backup, and our walkthrough on how to verify a WordPress backup before you need it covers the checks.
You also need a way into your site's files that does not depend on the WordPress dashboard. That means your hosting control panel's file manager or an SFTP login. If you do not have either, stop here and get access from your host first. If something goes wrong, the dashboard will not be available to help you.
How to disable WordPress file editor access in wp-config.php
-
Open your files. Log in to your host's file manager, or connect with SFTP. Prefer SFTP over plain FTP where your host supports it.
-
Find wp-config.php. It usually sits in the same folder as the
wp-admin,wp-contentandwp-includesfolders. Some setups keep it one folder higher, which WordPress allows. -
Download a copy first. Save it to your computer with a clear name, such as
wp-config-before-edit.php. This is your one-click undo. -
Search the file for
DISALLOW_FILE_EDIT. If the line is already there and set tofalse, changefalsetotrueand skip to step 6. Never add a second copy of the same line. -
Add the line in the right place. In the WordPress 7.1 sample file, there is a comment that says to add custom values between it and the "stop editing" line. Put the new line there:
/* Add any custom values between this line and the "stop editing" line. */ define( 'DISALLOW_FILE_EDIT', true ); /* That's all, stop editing! Happy publishing. */Older wp-config.php files may not have the "custom values" comment, and the wording of the stop-editing line has changed over the years. What matters is the position: above the stop-editing comment and well above the
require_onceline at the bottom of the file. -
Check the punctuation. Straight single quotes, a semicolon at the end, and nothing else on that line. Use a plain-text editor, never a word processor.
-
Save and reload your dashboard.
The WordPress.org wp-config.php documentation (last updated August 16, 2026, read October 2, 2026) lists this exact constant under the heading "Disable the Plugin and Theme File Editor", and asks that custom values go before the stop-editing line.
Check that it worked
Reload any admin screen while logged in as an administrator. Then:
- Block theme: open the Tools menu. Theme File Editor and Plugin File Editor should be gone.
- Classic theme: open Appearance and Plugins. The two File Editor entries should be gone.
- Front end: open your home page and one or two other pages in a private window. They should look exactly as before.
If the site shows an error instead, do not try to fix the new line in a panic. Upload the copy you saved in step 3 over the edited file, reload, and the site is back to where it started. Then read the line again slowly. The usual culprits are a missing semicolon or a curly quote.
DISALLOW_FILE_EDIT vs DISALLOW_FILE_MODS
Search results often mention a second constant, and mixing them up causes real trouble. Here is what the WordPress.org wp-config.php documentation says each one does:
| Constant | What it removes | What it leaves |
|---|---|---|
DISALLOW_FILE_EDIT |
The Theme File Editor and Plugin File Editor | Installing and updating plugins and themes from the dashboard |
DISALLOW_FILE_MODS |
Plugin and theme installation and updates from the admin area, and the file editors too | Editing files outside the dashboard |
The documentation is explicit that DISALLOW_FILE_MODS on its own covers the editors as well, so you never need both. For a one-person site, DISALLOW_FILE_EDIT is the one to use. DISALLOW_FILE_MODS blocks the dashboard updates you depend on, so only consider it if you already have a separate, working way to keep plugins and themes up to date.
What this setting does not stop
This is the part most guides skip, and it matters for setting your expectations.
It does not stop someone with an admin login from adding code another way. The Hardening WordPress page says so directly: the constant "will not prevent an attacker from uploading malicious files to your site, but might stop some attacks." With only DISALLOW_FILE_EDIT set, an administrator can still upload a plugin as a ZIP file, and a plugin can contain any code. The editor switch closes one door, not every door. The bigger protection is having fewer administrator accounts and strong logins on the ones you keep.
It does not touch your hosting access. SFTP, SSH and your host's file manager work exactly as before. If those logins are weak, this line does not help.
The editor's built-in safety check was never a defense. Since WordPress 4.9, saving a PHP edit triggers a check. The Make WordPress Core post "Code Editing Improvements in WordPress 4.9" (October 22, 2017) describes it: WordPress makes loopback requests to the editor screen and to the home page, and if either produces a fatal error, "the original PHP file is restored." That check looks for crashes. Code that runs cleanly passes it, and an attacker's code is written to run cleanly. It also looks at only those two pages, so an error that shows up somewhere else on the site is not what it was built to catch.
It does not remove your Additional CSS box. In the WordPress 7.1 code, Additional CSS uses a separate permission (edit_css) from the three that DISALLOW_FILE_EDIT removes: edit_themes, edit_plugins and edit_files.
If you genuinely need to change theme or plugin code
Turning the editor off does not stop you from customizing. It moves the work to safer places:
- Theme changes: use a child theme. WordPress's Theme File Editor documentation notes that edits made directly to a theme are lost when that theme updates, which is the same trap covered in our guide to updating a WordPress theme without losing customization.
- Style tweaks: use Additional CSS, which this setting leaves alone.
- PHP changes: download the file over SFTP, edit your copy, and upload it back, keeping the original so you can restore it in one step.
If you truly need the dashboard editor for a few minutes, change true to false in wp-config.php, do the work, and set it back to true straight away. Treat that as an exception, not a habit.
Some security plugins offer a checkbox that does the same job. We do not recommend one product over another, and you do not need a plugin for this: the wp-config.php line works on its own and keeps working even if a plugin is later deactivated.
How to undo it
Open wp-config.php the same way, then either delete the DISALLOW_FILE_EDIT line or change true to false. Save, reload the dashboard, and the editors return to the menus shown in the table near the top of this page. Take the same backup first; the risk of a typo is identical in both directions.
FAQ
Does disabling the file editor stop me from updating plugins?
No. DISALLOW_FILE_EDIT removes only the two editors. Plugin and theme installs and updates from the dashboard keep working. The constant that blocks updates is DISALLOW_FILE_MODS, which is a different line with a much bigger effect.
Can I turn off the Plugin File Editor but keep the Theme File Editor?
Not with this constant. DISALLOW_FILE_EDIT removes both editors together, and the WordPress.org wp-config.php documentation does not list a separate constant for each one.
My Theme File Editor is already missing. Why?
Check four things in order. On a block theme in WordPress 7.1, it lives under Tools, not Appearance. Your account may not hold the Administrator role. On multisite, only super admins see it. Or DISALLOW_FILE_EDIT or DISALLOW_FILE_MODS is already set in wp-config.php, possibly by whoever set up your hosting.
Will adding this line break my site?
The setting itself changes nothing your visitors see. The risk is in editing wp-config.php: a typo there can take the site offline. That is why you download a copy of the file first and keep a tested backup, so any mistake is a two-minute fix.
