WordPress hacked – what to do?
The first steps in the right order: make a copy, decide whether to take the site offline, clean up, rotate every credential, and get the Google warning lifted.
Before anything else, take a complete copy of the files and the database – even though it is infected. That copy is your evidence and your fallback, and you cannot recreate it once you start cleaning. Only then do you clean up. Doing it the other way round destroys the traces and sometimes the content too.
Take the site offline – yes or no?
There is no blanket answer, there are two cases. If your site serves malware to visitors, sends spam, or redirects to other addresses, take it offline immediately – every minute increases the damage to third parties.
If, on the other hand, a single file was altered and nothing of it reaches the outside, the site can stay reachable while you clean. A maintenance page beats a dead server: search engines read HTTP 503 as "will be back", a dropped connection they do not.
The order that saves work
1. Store a complete copy of files and database.
2. Replace the WordPress core, every theme and every plugin with fresh downloads from the official source – do not repair, replace. Note your own modifications first.
3. That leaves only `wp-content/uploads`, `wp-config.php` and the database to inspect individually. `uploads` has no business holding PHP files; anything ending in `.php` in there is suspicious.
4. Rotate every credential (see the next section).
5. Only now look for the cause: an outdated plugin, a stolen password, someone else's access at the host. Without an answer to the cause, the attacker comes back.
What really has to be rotated
New passwords for every administrator, for the database, for FTP/SFTP and for the hosting account. Then regenerate the security keys in `wp-config.php` – the eight `AUTH_KEY` values. That invalidates every existing login, the attacker's included; without this step a stolen session stays valid.
Also check the user list for accounts nobody created, and the scheduled tasks (cron) for entries you do not recognise. Both are the usual back doors.
Getting the Google warning lifted
If the search results say "This site may harm your computer" or the browser warns visitors, only a review via Google Search Console helps. There you submit the cleaned site for another check – and only once nothing is found any more. A rejected review prolongs the warning.
Expect a few days before the warning disappears. The site stays reachable meanwhile, but most visitors turn back at the warning screen.
Sources and further documentation
Frequently asked questions
Is restoring last week's backup enough?
Often not. At the start you usually do not know when the break-in happened – the backup may already contain the back door. And the hole the attacker came through is open again after the restore. A backup is a good starting point, not a substitute for cleaning up and finding the cause.
Does a security plugin find all malicious code?
No. Scanners compare against known patterns and against WordPress's original files. For the core and plugins from the official directory that works well. For custom code, commercial themes and inside the database they give you leads, not certainty. That is why replacing files wholesale is more reliable than cleaning individual findings.
How long does a cleanup take?
It depends on how much custom code is involved and whether the cause is found quickly. A standard installation with plugins from the official directory is usually clean again within a working day. Sites that have grown over years, with custom work, shop data or several installations on one server take longer – the cause analysis above all.
More guides
Locked out of the WordPress admin area
Read article →"Error establishing a database connection" – causes
Read article →Have a project in mind?
Get in touchAI assistant — may make mistakes. Not legally binding.