WordPress security: how to protect your site, step by step
How to protect a WordPress site: passwords and two-factor authentication, user roles, plugins and themes, wp-config.php settings, file permissions, XML-RPC, SSL, firewalls, backups and a monthly security checklist

WordPress powers a huge share of the websites on the internet, and that's exactly why it's a favourite target for bots. They aren't looking for your site in particular. They crawl millions of addresses around the clock, try passwords and check for outdated plugins with known vulnerabilities. A site without protection will sooner or later get caught in that net.
The good news is that WordPress security doesn't require you to be a developer. Most breaches are stopped by a few correct settings and habits that take minutes a week. In this guide we'll go step by step through logins and passwords, user roles, plugins and themes, wp-config.php settings, file permissions, XML-RPC, SSL, firewalls and backups. At the end you'll find a checklist you can run through once a month.
In short
- Most WordPress breaches come from outdated plugins and themes, weak passwords and forgotten installations, not from the core itself.
- Strong passwords, two-factor authentication, limited login attempts and regular updates have the biggest effect.
- Delete unused plugins and themes, and only install ones from trusted sources.
- Disable the file editor, set correct file permissions and block PHP execution in the uploads folder.
- Part of the protection happens at server level: a firewall, malware scanning and backups stored elsewhere.
Why WordPress sites are a common target
The reason is simple: scale. When one system runs so many websites, every vulnerability found in a popular plugin affects thousands of sites at once. Attackers write programs that scan the internet for that exact vulnerability and, within days, find every site that hasn't updated.

That's why a small business website or a personal blog is never "too insignificant to hack". Attacks are automated and don't pick and choose. A hacked site is used to send spam, redirect visitors to scam pages, mine cryptocurrency or hide files. The owner often only finds out when Google shows a warning or the host suspends the account.
The WordPress core itself is well maintained and gets fixes quickly. The weak spot is almost always something around it: a plugin, a theme, a password or an old installation nobody remembers. That's where protection starts.
Logins and passwords: your first line of defence
The login page is where bots knock most often. They try thousands of username and password combinations without stopping. This is what closes that door:
- A strong, unique password – at least 14–16 characters, generated by a password manager and not used anywhere else. If the same password has leaked from another site, bots will try it on yours too.
- No "admin" user – it's the first username bots try. If you have one, create a new administrator with a different name, assign the content to it and delete the old one.
- Two-factor authentication – besides your password, you're asked for a code from an app on your phone. Even if the password leaks, nobody can log in without your phone. Turn it on for every administrator at the very least.
- Limited login attempts – after a few failed attempts, the address is blocked for a while. That makes mass password guessing pointless.
Be careful with emails that claim to come from WordPress or your host and ask you to "verify your account" via a link. It's a classic way to steal an administrator password. You can read how to spot these emails in our article what is phishing.
If you use external apps that connect to the site, such as a mobile app or a publishing service, use separate application passwords from the user profile rather than your main password. That way you can revoke access for a single app if you need to.
Users and roles: give only the access people need
WordPress has several roles, each with different permissions. An Administrator can do everything, including installing plugins and changing code. An Editor manages all posts. An Author writes and publishes their own posts. A Contributor can write but not publish. A Subscriber can only read.
A common mistake is to make everyone on the team an administrator "so nothing gets in the way". If one of their passwords leaks, the attacker gets full control. Someone who writes articles needs the Author or Editor role, not administrator rights.
Review your list of users at least every few months. Delete accounts for people who no longer work with you and for agencies that have finished their project. If you see an administrator you don't recognise, that's a serious sign the site may already be compromised.
Plugins and themes: fewer, and only from trusted sources
Plugins are the most common way in for attackers. Every plugin is code written by someone else, and every bug in it is a potential door into your site. A few rules reduce the risk considerably:
- only install plugins and themes from the official WordPress directory or directly from the developer's website;
- never download premium themes and plugins "for free" from dubious sites, because they very often contain a hidden backdoor;
- before installing, check when the plugin was last updated and how many active installations it has;
- delete, rather than just deactivate, plugins and themes you don't use;
- keep only one default theme as a fallback and delete the other inactive themes.
A deactivated plugin is still on the server, and its code can be called directly if it contains a vulnerability. Deleting it is the only reliable way to close that door. The same goes for old test installations in subfolders. A site nobody updates gives access to the entire hosting account.

Updates: the cheapest protection there is
Most successful attacks exploit vulnerabilities that were fixed long ago. The owner simply didn't update. That makes updating the most effective security measure there is.
WordPress automatically installs minor core releases, which contain security fixes. For plugins and themes, you can turn on auto-updates one by one from the plugin list. Turn them on for simple, reliable plugins, and update complex ones, such as an online shop or a page builder, by hand after taking a backup.
Don't forget your PHP version either. Old versions no longer get security fixes, even if WordPress still runs on them. We explain how to update without breaking your site in our article how to update WordPress safely.
wp-config.php settings that improve security
The wp-config.php file holds your site's core settings, including the database credentials. A few lines in it close commonly exploited gaps. Add them above the line that says editing should stop here.
Disable the file editor in the admin area. That way nobody with stolen access can change theme and plugin code straight from the browser:
define( 'DISALLOW_FILE_EDIT', true );
Make sure debug mode is turned off on your live site. When it's on, it can show visitors file paths and other technical details that help an attacker:
define( 'WP_DEBUG', false );
The security keys (AUTH_KEY, SECURE_AUTH_KEY and the rest) encrypt the login cookies. If you've never changed them or you suspect a breach, generate new ones from the official WordPress generator at api.wordpress.org/secret-key/1.1/salt/ and replace the old ones. All open sessions, including anyone else's, are ended and everyone has to log in again.
File permissions and the uploads folder
Permissions control who can read, write and execute each file on the server. Permissions that are too broad, such as 777, let any process on the server change your files. These are the usual safe values:
| What | Permissions | Why |
|---|---|---|
| Folders | 755 | the owner can write, everyone else can only read and open |
| Files | 644 | the owner can write, everyone else can only read |
| wp-config.php | 440 or 400 | read-only, because it contains the database password |
| Any file or folder | never 777 | 777 lets anyone change the contents |
If you have SSH access, you set permissions with the chmod command. We explain how to connect to your server and why SSH and SFTP are safer than plain FTP in our article what is SSH.
The wp-content/uploads folder deserves special attention. That's where WordPress stores uploaded images and documents, and it should never contain executable PHP files. If an attacker manages to upload a PHP file through a vulnerable form, that's exactly where they'll try to run it from. On an Apache server, you block this with an .htaccess file in the uploads folder itself:
<Files *.php>Require all denied</Files>
On an nginx server, you do the same with a rule in the site's configuration:
location ~* /wp-content/uploads/.*\.php$ { deny all; }
If you're not sure which server you're on, ask your host. On well-configured WordPress hosting, this block is usually already in place.

XML-RPC and the REST API
XML-RPC is an old way for external programs to talk to your site. Today almost everything goes through the newer REST API, but XML-RPC is still on by default. The problem is that bots can use it to try hundreds of passwords in a single request, getting around your login attempt limit.
If you don't use the WordPress mobile app, Jetpack or older publishing services that rely on XML-RPC, you can safely turn it off. You can do that with a security plugin or with a server rule that blocks access to the xmlrpc.php file.
The REST API shouldn't be turned off completely, because the WordPress editor and many plugins depend on it. It can, however, expose a list of author usernames. If you want to hide them, restrict that specific endpoint rather than disabling the whole API.
SSL and HTTPS
Without an SSL certificate, your admin password travels to the server as plain text. Anyone on the same Wi-Fi network, in a café or hotel for example, can intercept it. Browsers mark such a site as "Not secure", and WordPress recommends HTTPS for every site.
Once the certificate is installed, check under Settings → General that both the WordPress Address and the Site Address start with https. Also add a redirect from http to https so the old, insecure version isn't left accessible.
Firewalls and bot protection
A web application firewall (WAF) checks every request before it reaches WordPress and stops known attack patterns: SQL injection attempts, probes for known plugin vulnerabilities and mass login attempts. It works like security staff at the door who know the faces of the usual troublemakers.
A firewall can sit at three levels: as a plugin inside WordPress, at server level with your host, or in front of the site through a service such as a CDN. A plugin is better than nothing, but it only kicks in after WordPress has loaded and the server has already spent resources on the request. Server-level protection stops the attack earlier and more cheaply.

A firewall isn't the same as DDoS protection. The first stops dangerous requests, the second stops the sheer volume of requests used to overload a site. We explain the difference in our article what is a DDoS attack.
Backups: your last line of defence
No protection is 100% effective. A backup is what turns a breach from a disaster into an hour of inconvenience. But only if it's done properly:
- backups run automatically, at least once a day for sites that change often;
- they're stored on a separate server, because a copy on the same server can be infected or deleted along with the site;
- they include both the files and the database;
- they go back at least a few weeks, because infections are often discovered days later;
- restoring has been tested at least once, rather than just assumed to work.
A backup from before the infection lets you bring back a clean version of the site and then close the door the attacker came in through.
What your host handles and what's up to you
WordPress security is a shared responsibility. Part of it lives on the server and you can't do it yourself, and part of it lives in your site and no host can do it for you.
Your host is responsible for a current, supported PHP version, a server-level firewall, DDoS protection, malware scanning, isolation between accounts and backups on a separate machine. That's why, when you choose hosting for a WordPress site, these are exactly the things to ask about. We cover what else to check before you order in our article how to choose WordPress hosting.
You're responsible for passwords and two-factor authentication, user roles, your choice of plugins and themes, updates if your host doesn't handle them, and the settings of the site itself. If you use WordPress hosting with active protection, much of the server-side work is done for you, but your admin password is still your job.
Security plugins: do you need one?
Security plugins bring together many of the measures in this guide: limiting login attempts, two-factor authentication, file scanning, disabling XML-RPC and alerts when something changes. For a site on shared hosting without server-level protection, they're useful.
They come at a cost, though. Heavy plugins with a built-in firewall slow the site down, because they check every request inside WordPress. Several security plugins at once often get in each other's way. Choose one well-maintained plugin and turn on only the features you actually need. If your host already has a firewall and malware scanning at server level, a lightweight plugin for login protection and two-factor authentication is usually enough.
Remember that a plugin doesn't replace good habits. A site with a security plugin but a password like "123456" and three years of unpatched plugins is still vulnerable.
WordPress security checklist
Run through this list once a month. It takes about fifteen minutes:
- all plugins, themes and the core are up to date;
- there are no unused plugins or themes;
- there is no "admin" user and no unknown administrators;
- every administrator uses two-factor authentication;
- login attempts are limited;
- the file editor is disabled;
- WP_DEBUG is off on the live site;
- PHP files can't run in the uploads folder;
- the site only works over HTTPS;
- XML-RPC is off if you don't use it;
- backups are on a separate server and the latest one is from yesterday;
- your PHP version is still supported.
How to tell something is wrong
In the admin area, open Tools → Site Health. WordPress checks for outdated components, an old PHP version, missing HTTPS and other problems by itself and ranks them by importance. It's a good first step in every monthly check.

Keep an eye on Google Search Console too. If Google finds malicious code or scam pages on your site, it will tell you in the Security issues report. Other warning signs are unknown administrators, new files with names you don't recognise, sudden redirects to other sites and emails that suddenly start landing in spam.
If you notice any of these, act straight away. We explain what to do in the first hour and how to clean up an infected site in our article what to do if your website has been hacked.
Frequently asked questions
Is WordPress secure?
Yes, the WordPress core is well maintained and gets security fixes quickly. Almost all breaches come from outdated plugins and themes, weak passwords and poor settings, not from the core itself.
What matters most for WordPress security?
Regular updates, strong passwords with two-factor authentication, and a small number of trusted plugins. These three things stop most automated attacks.
Do I need a security plugin?
It helps, especially if your host doesn't have a firewall and malware scanning at server level. Choose one well-maintained plugin and don't install several at once, because they clash and slow the site down.
Does changing the admin login URL help?
A little. It reduces bot noise in the logs, but it doesn't replace a strong password, two-factor authentication and limited login attempts. Treat it as an extra, not as your main protection.
Should I disable XML-RPC?
Yes, if you don't use the WordPress mobile app, Jetpack or external publishing services that rely on it. Bots can use XML-RPC to try many passwords in a single request.
What permissions should WordPress files have?
Usually 755 for folders, 644 for files and 440 or 400 for wp-config.php. No file or folder should ever have 777 permissions.
Are deactivated plugins dangerous?
Yes. A deactivated plugin is still on the server, and if its code has a vulnerability, it can be exploited. Delete the plugins you don't use.
How often should I back up my WordPress site?
At least once a day for sites that change often, such as online shops and blogs. Keep the backups on a separate server and test at least once that restoring works.
Conclusion
WordPress security isn't a one-off setting, it's a handful of habits. Update regularly, use strong passwords with two-factor authentication, keep only the plugins and users you need, disable the file editor and keep backups somewhere else. Leave server-level protection to your host and run through the checklist once a month. That makes your site a much harder target than the millions of sites bots crawl every day.
WordPress hosting with active protection. Every plan includes pre-installed, configured WordPress, SSL, protection against attacks, malware checks and restore from backup.
See the WordPress hosting plans · What to do if your site has been hacked


