In this guide: How to fix a hacked WordPress site step by step: the first 30 minutes, backing up the hacked state, cleaning or restoring, closing the vulnerability, and…
Discovering your website has been hacked is stressful. Your site may be redirecting visitors, showing spam, or flagged by Google. The key is to act methodically: contain the damage, clean or restore, close the hole, and recover your reputation.
Here’s the step-by-step process.
First 30 minutes
1. Confirm the hack.
Look for redirects, defaced pages, spam content, browser warnings, unknown admin users, or a security alert from your host or Google.
2. Contact your host.
Tell them what you’re seeing. Many hosts have security teams, malware scanners, and backups that can help — and they may need to know if your account is sending spam or attacking others.
3. Put the site in maintenance mode (if possible).
This protects visitors from malware or scam redirects while you work.
4. Change critical passwords — from a clean device.
- Hosting account and control panel
- SFTP/FTP and SSH
- Database user (update
wp-config.php afterward)
- All WordPress administrator accounts
- Email accounts connected to the site
Enable 2FA wherever possible. If your own computer might be infected, scan it first or use another device.
5. Log out all users — changing the security keys in wp-config.php (the “salts”) forces everyone to log in again.
Backing up the hacked state
Before changing files, take a full backup of the infected site (files and database) and label it clearly. You may need it to:
- Investigate how the attack happened.
- Recover content that was changed after your last clean backup.
- Provide information to a security professional.
Store it separately from your clean backups so you never restore it by accident.
Cleaning or restoring
Option A — Restore a clean backup (fastest)
- Identify when the infection began (check file modification dates, security logs, and when symptoms started).
- Restore a backup from before that date.
- Recreate any legitimate content added since then.
- Update everything immediately after restoring — the original vulnerability still exists in the backup.
Option B — Clean manually
- Replace WordPress core: download a fresh copy of the same version and replace
wp-admin and wp-includes (and root core files except wp-config.php). You can also run wp core verify-checksums to find modified core files.
- Reinstall plugins and themes from official sources — delete the old folders and install fresh copies. Remove any you don’t use.
- Inspect
/wp-content/uploads/ for PHP files or other files that shouldn’t be there.
- Check
wp-config.php and .htaccess for injected code or redirect rules.
- Clean the database: search posts, options, and widgets for injected scripts, iframes, and unknown links. Remove unknown admin users.
- Check scheduled tasks (cron) for malicious jobs.
- Scan again with a server-side scanner and remote scanner.
Option C — Professional cleanup
If the infection is complex, persistent, or you’re not comfortable editing files, hire a professional malware removal service or use your host’s cleanup service.
Closing the vulnerability
If you don’t fix how attackers got in, you’ll likely be hacked again.
- Update WordPress core, all plugins, themes, and PHP.
- Remove nulled, abandoned, or vulnerable plugins and themes.
- Review users: delete unknown accounts, reduce unnecessary admin roles.
- Enforce strong passwords and 2FA.
- Install a security plugin or WAF — see Best WordPress Security Plugins.
- Disable file editing in the dashboard (
DISALLOW_FILE_EDIT).
- Check file permissions.
- Review access logs (if available) to identify the entry point — suspicious POST requests to specific plugin files often reveal the vulnerability.
- Follow the full WordPress Security Checklist.
Requesting a Google review
If Google flagged your site:
- Open Google Search Console → Security issues.
- Confirm the issues are fixed and your site is clean.
- Click Request review and explain what you found and what you did to fix it.
- Reviews typically take from a few days to a couple of weeks.
Also:
- Remove spam URLs from Google’s index — make sure they return 404/410 and use the Removals tool for urgent cases.
- Resubmit your sitemap.
- Check other blacklists and request delisting if needed.
- Warn customers if their data may have been exposed, and follow applicable legal notification requirements.
After recovery
- Monitor your site daily for the next two weeks.
- Keep automatic daily off-site backups.
- Scan weekly.
- Document what happened and how you fixed it.
Further reading: official WordPress documentation
Key Takeaways: Fix a Hacked WordPress Site
- Contain first: contact your host, change passwords, and protect visitors.
- Back up the hacked state separately before cleaning.
- Restore a clean backup or replace core, plugins, and themes with fresh copies.
- Find and fix the vulnerability to prevent reinfection.
- Request a Google review once clean.