Skip to content
GPLWP Guides

How to protect a WordPress site from cyber attacks

Security Time About 45 minutes, plus time for a backup and restore check 6 steps Updated 15 Oct 2026

SECURITY
The short answer

Protect WordPress with current core, plugin and theme updates, strong unique passwords, two-factor authentication, HTTPS, tested backups and a server or plugin firewall. You can handle the basics manually, but a plugin is needed for practical malware scanning, login protection, alerts and central monitoring.

The route
  1. 01Create and test a full backup
  2. 02Update and remove unused software
  3. 03Lock down accounts and connections
  4. 04Apply the manual hardening route
  5. 05Monitor and prepare for recovery
  6. 06Use a security plugin for the fast way

What you need

  • Administrator access to WordPress
  • Access to your hosting control panel or server
  • A current full backup stored away from the site
  • A password manager and HTTPS already available

Create and test a full backup

Back up both the WordPress files and the database before changing security settings. Store at least one copy outside the hosting account, then confirm that you can restore it or ask your host to confirm the restore process.

A backup that has never been restored is an assumption, not a recovery plan. This matters because a firewall rule, update or permission change can make a site unavailable.

Update and remove unused software

Go to Dashboard → Updates and update WordPress, every active plugin and the active theme. Enable automatic updates where they suit your site, but keep backups because an update can conflict with a theme or plugin.

Delete plugins and themes you do not use rather than leaving them deactivated. Choose software that is actively maintained, and do not keep abandoned copies around as future attack paths.

Lock down accounts and connections

Give each person a separate account, use the least powerful role they need, remove old users and avoid predictable administrator usernames. Use a long, unique password for every administrator account and turn on two-factor authentication for administrators.

Force the dashboard and login process over HTTPS. WordPress core does not provide two-factor authentication for normal administrator logins, so you need a reputable plugin or an identity provider for that control.

Apply the manual hardening route

At minimum, ask your host for a managed web application firewall and login rate limiting. In wp-config.php, disable the dashboard file editor with define( 'DISALLOW_FILE_EDIT', true );, after taking a backup. Use sensible file ownership and permissions, and protect the file containing your database credentials.

You can also disable or restrict XML-RPC if your site does not need it. Check first: Jetpack, the WordPress mobile app and some integrations rely on it, so a blanket block can break them. Manual hardening is fine for a small, low-risk site if you can maintain it, but it does not give you one place for malware scans, activity logs, alerts and two-factor authentication.

Monitor and prepare for recovery

Review failed logins, new administrator accounts, unexpected plugin or theme changes and unusual traffic. Set email alerts for important security events, and check that your host, backup system and firewall are still reporting normally.

If the site is hacked, do not simply delete the visible bad file and carry on. Put the site into a controlled maintenance state, preserve logs, change hosting, database, WordPress and administrator passwords, scan the files and restore from a known-clean backup or use a professional incident response service.

Use a security plugin for the fast way

For most live sites, install WP Cerber Security and configure its firewall, login protection, two-factor authentication, malware scanning, activity monitoring and email alerts. Review its XML-RPC, REST API, bot and anti-spam settings rather than enabling every restriction without checking what your site uses.

This is faster than assembling separate controls, especially when you need a firewall, malware and integrity checks, brute-force protection and ongoing alerts. Keep updates, HTTPS, least-privilege accounts and tested backups in place: the plugin is an additional layer, not a replacement for them.

The fast route

Let WP Cerber Security do it

All-in-one firewall, malware scanning, login protection, and anti-spam; a broader shield than a plugin focused only on login security.

Get WP Cerber Security

Sources

  1. developer.wordpress.org /advanced-administration/security/?utm_source=openai
  2. developer.wordpress.org /advanced-administration/security/brute-force/?utm_source=op…
  3. developer.wordpress.org /advanced-administration/security/hardening/?utm_source=open…

Questions

Can I protect WordPress without a security plugin?
Yes, you can cover the foundation manually with updates, HTTPS, strong unique passwords, limited administrator access, tested backups and a host-level firewall. The drawback is maintenance: WordPress core does not include administrator two-factor authentication, central malware scanning or a complete security activity dashboard, so a plugin or managed security service becomes practical for most live sites.
Should I disable XML-RPC in WordPress?
Disable or restrict XML-RPC only when you have confirmed that your site does not need it. It is a common target for automated login attempts, but Jetpack, the WordPress mobile app and some integrations can rely on it; blocking it without checking can produce connection errors. Prefer targeted rate limiting or allowlisting when XML-RPC is required.
Does changing the WordPress login URL stop attacks?
Changing or obscuring the login URL may reduce background noise, but it does not secure the site by itself. Attackers can find other entry points, and a discovered URL leaves you needing strong passwords, two-factor authentication, rate limiting, current software and monitoring. Treat login URL changes as a minor additional measure, not your main defence.
What should I do if my WordPress site has already been hacked?
Take the site out of normal service, preserve useful logs, change all relevant passwords and investigate before making random deletions. Restore from a known-clean backup if possible, update every component, remove untrusted software and check administrator accounts, database content and scheduled tasks. If you cannot establish when the compromise happened, use a specialist rather than trusting the first backup you find.