In short
Most WordPress sites are compromised not through core but through outdated plugins, weak passwords and brute-force login attempts. The most effective measures, in order of priority, are: an update policy, deleting unused plugins, strong passwords and two-factor authentication (2FA), login attempt limits, disabling file editing with DISALLOW_FILE_EDIT, blocking XML-RPC, correct file permissions and regular backups.
In this guide
- Priority table
- 1. Set an update policy
- 2. Delete unused and nulled plugins
- 3. Strong passwords and two-factor authentication (2FA)
- 4. Limit login attempts
- 5. Clean up users and roles
- 6. Disable file editing in the dashboard
- 7. Block XML-RPC
- 8. Force HTTPS
- 9. Fix file permissions
- 10. Block PHP execution in the uploads folder
- 11. Regenerate security keys
- 12. Backups and monitoring
- Next step: start from a secure foundation
WordPress security is less about installing a single plugin and more about applying a few correct settings for good. On most hacked sites, the problem is not WordPress core; it is an outdated plugin, a guessable password or automated login attempts that go on for days. The 12 settings below are ordered by priority to close the doors attackers use most often. The first five alone eliminate most of the risk.
Priority table
| # | Setting | Impact | Difficulty |
|---|---|---|---|
| 1 | Update policy | Very high | Easy |
| 2 | Deleting unused and nulled plugins/themes | Very high | Easy |
| 3 | Strong passwords and 2FA | Very high | Easy |
| 4 | Login attempt limits | High | Easy |
| 5 | User and role cleanup | High | Easy |
| 6 | Disabling file editing | High | Easy |
| 7 | Blocking XML-RPC | Medium | Easy |
| 8 | Forcing HTTPS | Medium | Easy |
| 9 | File permissions | Medium | Medium |
| 10 | Blocking PHP in the uploads folder | Medium | Medium |
| 11 | Regenerating security keys | Medium | Easy |
| 12 | Backups and monitoring | Recovery | Medium |
1. Set an update policy
Most known vulnerabilities are exploited in plugins that were patched long ago. Minor (security and maintenance) WordPress core updates install automatically by default; do not turn this off. For plugins, use the "Enable auto-updates" link on the Plugins screen for trusted, frequently updated plugins. Update critical plugins such as payment and page builder plugins on a weekly routine, testing them in a staging environment first. You can set core update behavior explicitly in wp-config.php:
define( 'WP_AUTO_UPDATE_CORE', 'minor' );Treat your PHP version as part of this policy too: a site running on a PHP version that no longer receives security support is at risk even if WordPress is up to date.
2. Delete unused and nulled plugins
As long as a deactivated plugin's files remain on the server, they can be called directly and may contain vulnerabilities. Do not just deactivate plugins and themes you do not use; delete them. Never install "nulled" (pirated) copies of premium plugins; these files often contain backdoors. Replace plugins that have not been updated in a long time with actively developed alternatives.
3. Strong passwords and two-factor authentication (2FA)
Two-factor authentication asks for a one-time code generated by an app on your phone in addition to your password. Even if your password leaks in a data breach, nobody can get into your account. How to set it up:
- Use passwords of at least 16 characters, not used anywhere else, on all administrator and editor accounts; a password manager makes this easier.
- Install a 2FA plugin that supports TOTP (for example, the Two Factor plugin on WordPress.org).
- Make 2FA mandatory for administrator accounts and store the backup codes somewhere safe.
4. Limit login attempts
Bots can try thousands of passwords per hour against wp-login.php. This puts accounts at risk and also eats up your server resources. Use a plugin that limits login attempts to, for example, block an IP address for 20 minutes after 5 failed attempts, and for longer on repeat offenses. These numbers are a starting point; adjust them to the size of your team. If you manage your own server, you can do the same at the server level with Fail2ban.
5. Clean up users and roles
- If there is a user named "admin", create a new administrator account, attribute the content to it and delete the old one.
- Give everyone the lowest role that lets them do their job: someone who writes content needs the Author or Editor role, not Administrator.
- Remove accounts of departing employees and agencies immediately.
- In the profile, set "Display name publicly as" to something different from the username.
Usernames are not secret: author archives such as /?author=1 and the REST API users endpoint (/wp-json/wp/v2/users) can reveal them. So base your security on the strong passwords, 2FA and login limits from items 3 and 4, not on hiding usernames. If you want to disable user enumeration, use a security plugin that supports it, but treat it as an extra layer.
If you work with agencies, create a separate account in their name instead of sharing your own administrator account. When the work is done, you only need to delete that account, and the activity log shows separately who made which change.
6. Disable file editing in the dashboard
Appearance > Theme File Editor and the plugin editor let anyone who takes over an administrator account write PHP code directly to the server. Disable these editors by adding this line to wp-config.php:
define( 'DISALLOW_FILE_EDIT', true );The stricter DISALLOW_FILE_MODS constant also blocks installing and updating plugins from the dashboard. Do not use it unless you manage updates with WP-CLI or FTP; otherwise updates pile up and you undermine item 1.
7. Block XML-RPC
XML-RPC (xmlrpc.php) is a legacy interface that provides remote access to WordPress. Because it allows many password attempts in a single request, it is frequently used in brute-force attacks. If you have no dependency on it, such as Jetpack or a mobile app that uses XML-RPC, block it completely by adding the following to the .htaccess file in your site's root directory:
<Files xmlrpc.php>
Require all denied
</Files>Then check from the command line that xmlrpc.php returns 403:
curl -s -o /dev/null -w "%{http_code}\n" https://alanadiniz.com/xmlrpc.phpIf the output is 403, the rule is working. If you see 405 or 200, make sure the rule was added to the correct .htaccess file, outside WordPress's own rewrite block. Pingback notifications also run over XML-RPC, so they stop arriving after the block; for most sites this is no loss.
8. Force HTTPS
Login credentials and session cookies should never travel over an unencrypted connection. If your SSL certificate is installed, redirect the whole site to HTTPS and force HTTPS in the admin dashboard:
define( 'FORCE_SSL_ADMIN', true );How to redirect all traffic to HTTPS with .htaccess is covered in our guide to 301 redirects and forcing HTTPS.
9. Fix file permissions
Recommended values: 755 for folders, 644 for files. For wp-config.php, which contains your database password, use the most restrictive value your server allows (usually 640 or 600). Never use 777 on any file or folder. To fix permissions in bulk over SSH:
cd ~/public_html
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chmod 640 wp-config.phpCheck your site after running the commands; if you get errors with 640, go back to 644 and ask the support team about the server configuration.
10. Block PHP execution in the uploads folder
The wp-content/uploads folder should only hold images and documents. Attackers try to drop PHP files there through a vulnerable upload form. Create a new .htaccess file in this folder:
<FilesMatch "\.(php|phtml|phar)$">
Require all denied
</FilesMatch>This rule works on Apache and LiteSpeed servers; on servers running Nginx, the equivalent rule goes into the server configuration.
11. Regenerate security keys
The eight lines in wp-config.php, such as AUTH_KEY and SECURE_AUTH_KEY, sign session cookies. Regenerate these values when you suspect a leak or take over a site; every user is logged out and stolen cookies become invalid. You can get new values from the official WordPress secret key generator and paste them in place of the old lines.
12. Backups and monitoring
No setting reduces risk to zero; backups are what save you on a bad day. Back up your files and database regularly and keep at least one copy outside your hosting account. You can find the steps in our guide to backing up and restoring in cPanel. An activity log plugin that records admin logins and file changes also helps you spot an unexpected administrator account or modified core files early. If you have SSH access, the wp core verify-checksums command checks whether your core files are original.
If your site has already been hacked, these settings alone are not enough; you need to clean it up first. Follow our guide to cleaning up a hacked WordPress site.
Next step: start from a secure foundation
These 12 settings protect the application layer; on the infrastructure side, an up-to-date server environment and a free SSL certificate are the baseline. Sunucu Atlas WordPress hosting plans come with a free SSL certificate, the LiteSpeed web server and NVMe storage; through cPanel you can keep your PHP version current and easily edit file permissions and .htaccess rules with File Manager. To set up a new site correctly from the start, install it in one click with WP Toolkit and apply this list on day one. If you do not want to hit resource limits during bot attacks, consider WordPress plans with higher CPU limits. If you want to move your existing site to a secure environment, explore our WordPress hosting options running in our Istanbul data center, and if you get stuck, open a support ticket with the Sunucu Atlas team (support is provided in Turkish).
Frequently asked questions
Which plugin do I need for WordPress security?
A single plugin is not enough. You can use plugins for 2FA and login limits, but settings such as your update policy, disabling file editing, blocking XML-RPC and file permissions are handled in wp-config.php and .htaccess.
Will disabling XML-RPC break anything?
Jetpack and some mobile apps or remote publishing tools that use XML-RPC will stop working. If you do not use them, there is no downside to disabling it.
Is it safe to turn on auto-updates for plugins?
Yes, for trusted plugins that are updated frequently. Updating critical plugins such as payment and page builder plugins in a staging environment first reduces the risk of incompatibilities.
What is the correct permission for wp-config.php?
Use the most restrictive value your server allows, usually 640 or 600. If the site shows errors, use 644; never use 777.
How do I change the admin username?
WordPress does not let you change a username from the dashboard. Create a new administrator account, and when deleting the old account, choose the option to attribute its content to the new account.
If my site has been hacked, are these settings enough?
No. You first need to remove the malicious files and reset passwords and security keys; these settings prevent the site from being compromised again after the cleanup.