How to Clean an Infected WordPress Website
A cleanup order that finds the entry point instead of just deleting symptoms.
Cleaning a WordPress site is three jobs: remove the malicious code, close the way in, and prove nothing was left behind. Skip the second and you will do all three again next month.
Before you touch anything
- Take a snapshot of files and database as they are. This is your evidence.
- Note what you know: when it started, what changed recently, what the host or Search Console said.
- Take the site offline or into maintenance mode if it is actively harming visitors.
Cleanup
- Replace WordPress core with a fresh official copy of the same version, preserving only
wp-config.phpandwp-content. - Reinstall every plugin and theme from source rather than editing files — deleting and reinstalling is faster and more reliable than cleaning by hand.
- Delete anything that is not a legitimate plugin or theme, including plugin-shaped directories that are not in the directory.
- Remove PHP files from
uploads, then block PHP execution there. - Clean the database: injected content in posts and options, rogue administrators, unexpected scheduled tasks.
- Reset every credential — WordPress admins, database, hosting, FTP/SSH, API keys — and regenerate the salts.
Close the way in
Now identify the entry point: an unpatched plugin with a known vulnerability, a stolen credential, a shared-hosting neighbour, or an outdated PHP version. Scan the site and patch everything in the fix-today bucket. If a vulnerable plugin has no patched version, replace it before going back online.
Prove it is clean
- Compare core files again — no modifications.
- Re-check as a logged-out mobile visitor from a search referrer.
- Request review in Search Console and with any blacklist that flagged you.
- Watch logs for a fortnight for repeat attempts on the endpoint that was used.
If any of this is beyond what you want to take on: malware removal and emergency repair.
Hardening reduces the damage. Patching removes the hole. Scan your site free to see what still needs patching.