Finding out your WordPress site has been hacked is stressful. Visitors may see spam, redirects or browser warnings, and Google may flag the site as dangerous. Acting calmly and methodically gets the site clean faster and stops it being reinfected. This is the recovery process I follow when clients come to me with a hacked site.
Confirm the hack
Common signs include unexpected redirects to other sites, spam pages appearing in Google results, new admin users, unknown files, a browser or Google warning, hosting suspension notices or emails from your security plugin. Some hacks only show to search engines or mobile visitors, so check from several devices.
My guide to signs your website has been hacked lists the symptoms in more detail. Search Google for site:yourdomain.com to spot spam pages.
Do not panic, and do not delete everything
Deleting the whole site or restoring blindly can destroy evidence and still leave the vulnerability open. Take a full backup of the current, infected site first and label it clearly. It helps identify how the attack happened and recover content added since your last clean backup.
Tell your host. Many hosts help with cleanup, and they need to know if your account is sending spam or attacking other sites.
- 1Back up infected siteEvidence and content
- 2Change passwordsEverything, plus salts
- 3Scan and cleanReplace core, plugins, themes
- 4Close the holeFind the cause
- 5Request reviewsGoogle and blocklists
Change every password
Change passwords for WordPress administrators, hosting, SFTP, the database, email accounts and your domain registrar. Use long, unique passwords from a password manager and enable two-factor authentication. Assume any password that was stored on or used with the site may be compromised.
Update the security keys and salts in wp-config.php, which logs out every user and invalidates stolen session cookies.
Put the site into maintenance if needed
If the site is redirecting visitors to malicious pages or serving malware, protect visitors by putting it into maintenance mode or temporarily restricting access while you clean it. This also limits damage to your reputation and search visibility.
For stores, consider pausing checkout until you are confident payment pages have not been tampered with. See WooCommerce security basics.
Scan for malware
Use a server-side scanner, such as your host’s malware scanner, Wordfence or Sucuri, to find infected files. Server-side scans see files that remote scanners cannot. Look for recently modified files, PHP files inside the uploads folder and code with obfuscated strings such as base64_decode or eval.
My guide to scanning WordPress for malware explains the tools and what results mean.
Replace core files, themes and plugins
Delete and replace WordPress core files with fresh copies from WordPress.org, keeping wp-config.php and wp-content. Reinstall every plugin and theme from official sources rather than trying to clean them line by line. Remove anything you do not use.
Check wp-config.php, .htaccess and the root folder carefully for injected code or unfamiliar files. Compare with clean versions.
Clean the uploads folder and database
The uploads folder should contain media, not PHP files. Remove any PHP files you find there. In the database, look for unknown administrator accounts, injected scripts in posts and options, and spam links. Search for script tags and suspicious domains.
Back up the database before editing. If the infection is widespread, restoring a clean database backup from before the hack may be quicker, then re-adding recent content.
Restore from a clean backup if possible
If you have a backup from before the infection, restoring it can be the fastest route. Make sure the backup is genuinely clean, since some infections lie dormant for weeks. After restoring, immediately update everything and change passwords, or the same vulnerability will be exploited again.
See how to restore a WordPress backup for the process.
Find and close the vulnerability
Cleaning without fixing the cause leads to reinfection. Common causes are outdated or nulled plugins, weak passwords, compromised hosting accounts and vulnerable themes. Check server access logs around the time the infection started for suspicious requests.
Update or replace the vulnerable component and follow my security hardening checklist.
Request reviews and clean up search results
If Google flagged the site, fix the issue, then request a review in Search Console’s Security issues report. Other blocklists, such as those used by antivirus vendors, have their own review processes. See removing a Google blacklist warning.
Remove spam pages from search with 410 responses or the Removals tool, and submit a clean sitemap.
Communicate if data was affected
If customer data, such as names, emails or orders, may have been accessed, you may have legal obligations to notify affected people and authorities, depending on your location. Get advice quickly, as deadlines can be short.
Be honest and clear with customers about what happened and what you have done. Transparency protects trust far better than silence.
Prevent it happening again
After cleanup, add a firewall, enable 2FA, set up malware scanning, an activity log and uptime monitoring, and schedule regular updates and off-site backups. Review user accounts and remove unnecessary access.
If your site is hacked right now, contact me or message me on WhatsApp. Malware cleanup and ongoing protection are part of my website protection service.
Key takeaways
- Back up the infected site before cleaning to keep evidence and content.
- Change every password and update security keys immediately.
- Replace core, plugins and themes from official sources.
- Find and fix the vulnerability, or the site will be reinfected.
Frequently asked questions
How did my site get hacked?
Most often through an outdated or nulled plugin, weak passwords or a compromised hosting account.
Can I clean a hacked site myself?
Simple infections, yes. Widespread or recurring infections are best handled by a professional.
Will my host clean my site?
Some hosts offer cleanup; others only notify you. Check your plan.
How long does recovery take?
Simple cleanups take hours. Complex infections and blacklist reviews can take several days.
Why does the hack keep coming back?
The vulnerability or a hidden backdoor remains. Replace all code and close the entry point.
Will being hacked hurt my SEO?
It can if spam pages are indexed or Google shows warnings. Cleaning quickly and requesting reviews limits the damage.
