How to Clean a Hacked WordPress Site (Step-by-Step Malware Removal)
A calm, methodical guide to cleaning a hacked WordPress site — back it up, find the malware, remove it, and stop it coming back.
Finding out your WordPress site is hacked is stressful, but cleaning it is a methodical job, not a panic. Rushing — deleting files at random, restoring an old backup over the infection — usually makes things worse or hides the real problem. This guide walks through cleaning a hacked WordPress site in the right order, so the malware is actually gone and stays gone.
Before you touch anything: back up
Take a full backup of the site exactly as it is now — all files plus the database. A compromised backup is still valuable: it preserves the evidence of how you were attacked, and you can always extract clean content from it later. Never start deleting before you have this snapshot.
If you are not yet sure the site is infected, first read how to scan WordPress for malware for free to confirm it.
Step 1: Find the malware
You can’t clean what you can’t see. Run three read-only checks:
- Core integrity — compare every WordPress core file against the official WordPress.org checksums to find modified, missing or fake core files.
- Malware scan — heuristically scan every PHP file in plugins, themes and uploads for web-shell and backdoor indicators, with the exact file and line.
- File baseline — if you have one, compare it to see precisely what changed.
Forvault Security (free on WordPress.org) runs all three from the dashboard without changing a single file, so it is safe on a live, infected site.
Step 2: Remove the malicious code
- Reinstall WordPress core from the official source to overwrite any tampered core file.
- Replace infected plugins and themes with clean copies from their official source — don’t try to hand-edit injected code out of a plugin you can simply reinstall.
- Delete unknown files the scan flagged in the site root, in core folders and in
wp-content/uploads/. - Clean injected code from your own custom theme files (
functions.php,header.php) and from the database (injected scripts in posts, options or widgets).
Step 3: Close the door — remove persistence
This is the step most clean-ups skip, and it’s why sites re-infect. Attackers leave a way back in:
- Delete any administrator account you don’t recognise, and check for users hidden by the attacker.
- Inspect WP-Cron for malicious scheduled tasks that re-drop the payload.
- Rotate every password and the secret keys in
wp-config.php. - Look for rogue must-use plugins in
wp-content/mu-plugins/.
Step 4: Verify and lock it down
- Re-scan until the site comes back clean.
- Take a fresh file baseline so any future change is obvious within hours.
- Update everything, delete unused plugins and themes, block PHP execution in
uploads/, and enable two-factor authentication.
For continuous protection — scheduled scans, critical-file watching, new-admin alerts and one-click quarantine — the Premium add-on turns detection into ongoing response. And if you’d rather hand the whole clean-up to a specialist, we offer a done-for-you malware removal service.
Frequently asked questions
Can I just restore a backup to fix a hack?
Only if you are certain the backup predates the infection and you have also closed the entry point. Otherwise you restore the same vulnerability and get reinfected. Clean first, then harden.
How long does it take to clean a hacked WordPress site?
A straightforward infection can be cleaned in an hour or two. A deeply embedded one with multiple backdoors takes longer — the time is in finding every piece of persistence, not in deleting files.
Is Forvault Security free?
Yes. The malware scan, core integrity check and file baseline are all free on WordPress.org, with no trial limits.