WordPress Security 101: A Practical Checklist

Quick Summary
- Turn on auto-updates for plugins and themes, use long passwords with two-factor authentication, limit failed logins and give every user the lowest role they need.
- Set DISALLOW_FILE_EDIT in wp-config.php, block PHP in the uploads folder, add security headers, use HTTPS and keep file permissions at 755 for folders and 644 for files.
- Block xmlrpc.php only if Jetpack, the mobile app and pingbacks don't need it, and limit the rule to that one file, or every visitor gets a 403 error on the whole site.
For WordPress security, keep WordPress, plugins and themes updated, protect every login with a strong password and two-factor authentication, limit failed logins, give each user the lowest role that works, and keep backups off the server. Then close the common gaps: HTTPS, security headers, the dashboard file editor, PHP in the uploads folder, XML-RPC if nothing uses it, and loose file permissions. The server rules below are for Apache, with the Nginx versions after them. They follow WordPress’s hardening guide and OWASP’s cheat sheets.
1. Keep WordPress, plugins and themes updated
WordPress installs its minor and security releases on its own. Plugins and themes only update themselves if you turn it on: on the Plugins screen, click Enable auto-updates next to each plugin, and do the same for each theme under Appearance > Themes (WordPress 5.5 and later).
Delete plugins and themes you don’t use; deactivating one leaves its files on the server. Tools > Site Health flags outdated WordPress, plugins, themes and PHP, inactive plugins, and a site without HTTPS. Run a PHP version that still gets security fixes: in September 2026 that means PHP 8.2 (supported until the end of 2026) or newer, as listed on php.net.
2. Use strong passwords and two-factor authentication
OWASP’s Authentication Cheat Sheet treats passwords shorter than 15 characters as weak when there is no second factor, and advises against rules that force capitals or symbols. Use a password manager, or the Set New Password button on your profile, which suggests a random 24-character password.
Add two-factor authentication to every account that can publish or change settings. OWASP calls it by far the best defense against most password attacks. WordPress doesn’t include it, but the free versions of Wordfence and Kadence Security (section 12) both add it.
3. Limit login attempts
WordPress doesn’t limit failed logins by itself, so a bot can keep guessing. Login Lockdown & Protection blocks an IP address after 3 failed logins within 5 minutes, for an hour, by default, and adds a captcha to the login form. Wordfence and Kadence Security include the same kind of brute-force protection, so you don’t need both.
4. Give every user the lowest role they need
Give each person their own account, with the lowest of WordPress’s roles that lets them do their work:
- Administrator: plugins, themes, settings and users. Keep it to the people who run the site.
- Editor: everyone’s posts and pages. On a single site, editors can also post unfiltered HTML, scripts included, just like administrators.
- Author: uploads files and publishes their own posts.
- Contributor: writes posts but can’t publish them or upload files.
- Subscriber: only manages their own profile.
Remove accounts nobody uses any more, and don’t use admin as a username. If Settings > General > Anyone can register is on, keep New User Default Role at Subscriber; Site Health warns when it is set to Editor or Administrator.
5. Disable file editing
The Theme File Editor and Plugin File Editor let an administrator change PHP files from the browser, so a stolen admin login is enough to run any code. Add this line to wp-config.php, above the /* That's all, stop editing! Happy publishing. */ comment:
// Disallow file edit
define( 'DISALLOW_FILE_EDIT', true );It removes the edit_themes, edit_plugins and edit_files capabilities from everyone, administrators included; installing and updating plugins still works. The stronger DISALLOW_FILE_MODS also blocks every install and update, automatic updates included, so only use it if you deploy updates another way.
6. Disable XML-RPC if nothing uses it
xmlrpc.php is an older API that lets other programs log in and publish with a username and password. Before you block it, check that nothing on your site needs it:
- Jetpack uses it to connect your site to WordPress.com.
- The WordPress mobile app needs it to work with a self-hosted site.
- Pingbacks from other blogs arrive through it.
- Desktop blog editors publish through the Blogger and MetaWeblog APIs it provides.
If you use none of these, block it (more background in WPBeginner’s security guide). Add this to the .htaccess file in your site’s root folder:
# Block WordPress xmlrpc.php requests
<Files xmlrpc.php>
Require all denied
</Files>To keep it open for one service, replace Require all denied with Require ip followed by that service’s IP address, for example Require ip 123.123.123.123.
An earlier version of this snippet was missing the <Files xmlrpc.php> lines. Without them the rule applies to every file on the site, so every visitor except the allowed IP address gets a 403 Forbidden error. If you copied it, replace it.
Without access to server files, add_filter( 'xmlrpc_enabled', '__return_false' ); in functions.php turns off only the XML-RPC methods that need a login. Pingbacks still work.
7. Block PHP in uploads and protect core files
The uploads folder only needs to serve images and files, so PHP has no reason to run there (WPBeginner explains the method). Create a file called .htaccess in /wp-content/uploads/ with:
<Files *.php>
Require all denied
</Files>For wp-includes, the hardening guide blocks direct requests to the files that are only meant to be included by WordPress. Add these rules to the root .htaccess, outside the # BEGIN WordPress and # END WordPress lines, because WordPress rewrites everything between them. The last three lines also deny requests for wp-config.php, and Options -Indexes turns off directory listing, so a folder without an index file returns 403 instead of a list of its files:
# Block the include-only files.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
</IfModule>
Options -Indexes
<Files wp-config.php>
Require all denied
</Files>On multisite, leave out the ^wp-includes/[^/]+\.php$ line, which would stop ms-files.php from serving uploaded images.
On Apache 2.4 these rules return 403 for xmlrpc.php, wp-config.php, the include-only files and PHP in uploads, while pages, images, scripts and wp-login.php still load. They use Apache 2.4’s Require syntax; the older Order/Deny/Allow lines need mod_access_compat.
Nginx doesn’t read .htaccess files, so on Nginx the same blocks go in the server configuration. Nginx checks regular-expression locations in the order they appear, so put the uploads rule above your location ~ \.php$ block. Directory listing is already off unless autoindex is turned on.
location = /xmlrpc.php { deny all; }
location = /wp-config.php { deny all; }
location ~* ^/wp-content/uploads/.*\.php$ { deny all; }8. Use HTTPS everywhere
Get a TLS certificate from your host or Let’s Encrypt, then change both addresses in Settings > General to https://. If HTTPS already works on your server, Tools > Site Health shows an Update your site to use HTTPS button that does this for you (WordPress 5.7 and later). Once the site address starts with https://, WordPress also forces HTTPS for the login and the dashboard. Redirect the old http:// addresses with an .htaccess redirect.
9. Add security headers
WordPress sends X-Frame-Options, a frame-ancestors policy and a Referrer-Policy on the login and admin screens, but no security headers on the front end. Add them to the root .htaccess:
<IfModule mod_headers.c>
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"
</IfModule>The values come from OWASP’s HTTP Headers Cheat Sheet, except one: OWASP suggests X-Frame-Options: DENY, but the Customizer previews your pages in a frame on your own domain, so SAMEORIGIN, which WordPress itself sends, fits better. On Nginx, the same headers are add_header lines with always.
When the whole site and all its subdomains work over HTTPS, OWASP also recommends Strict-Transport-Security: max-age=63072000; includeSubDomains; preload. Browsers that have seen it refuse plain HTTP for your domain for two years, so if HTTPS or the certificate breaks, visitors may not be able to reach the site at all. Add it last.
10. Set file permissions
WordPress’s file permissions guide recommends 755 or 750 for directories, 644 or 640 for files, and 440 or 400 for wp-config.php, so other users on the server can’t read it. No directory should ever be 777, not even uploads. Files should belong to your user account, not the web server’s. Over SSH:
find /path/to/your/wordpress/install/ -type d -exec chmod 755 {} \;
find /path/to/your/wordpress/install/ -type f -exec chmod 644 {} \;
chmod 440 /path/to/your/wordpress/install/wp-config.php440 and 400 only work when PHP runs as your user or its group. If the site stops loading after the last command, set wp-config.php to 640 and ask your host.
11. Keep backups off the server
Back up the files and the database regularly, keep the copies somewhere other than the web server, keep more than one date, and test a restore before you need it. UpdraftPlus is one maintained plugin that sends scheduled backups to Dropbox, Google Drive or Amazon S3; your host’s backups are another option.
12. Choose maintained plugins and run one security plugin
Every plugin adds code that can have security holes. Before installing one from wordpress.org, check Last updated, Tested up to and whether support questions get answers. A plugin that hasn’t been tested with the latest three major WordPress releases shows a notice that it “may no longer be maintained or supported”. The hardening guide’s advice is to stick to the WordPress.org directory or well-known companies, which rules out “nulled” copies of paid plugins.
A security plugin covers several items on this list at once. They overlap, so pick one:
- Wordfence Security – Firewall, Malware Scan, and Login Security: the free version has a firewall, a malware scanner, two-factor authentication, login attempt limits and a login captcha.
- Kadence Security (formerly Solid Security and iThemes Security): the free version has two-factor authentication, brute-force protection and file change detection.
Related articles
- forcing HTTPS with an .htaccess redirect: another server rule that lives in the same file
- stopping spam in comments and sign-up forms: the next layer after login protection

