WordPress Website Hacked? What to Do First (Step by Step)
Discovering your WordPress site has been hacked is a horrible moment — visitors are being redirected to spam sites, Google may be warning people away, and you don't know what has been touched. Take a breath. Hacked WordPress sites are recovered every day, and the damage is usually reversible if you work in the right order. This is the sequence I follow when a client brings me a compromised site.
Step 1: Confirm it's really a hack
Common signs: your site redirects visitors (especially mobile or search visitors) to other sites; new pages or posts you didn't write, often pharmaceutical or casino spam; unfamiliar admin users; Google Search Console emails about hacked content; your host suspends the account for malicious activity; or the browser shows a red 'Deceptive site ahead' warning. One or two of these is enough to treat it as a security incident. Note the important detail: the visible symptom is rarely the whole infection — cleaning only what you can see is why hacks come back.
Step 2: Lock the doors before you clean
- Change every password: WordPress admin accounts, hosting control panel, FTP, and the database user. Attackers often keep a stolen credential as their way back in.
- Force-logout all sessions: in
wp-config.php, replace the salt keys (theAUTH_KEY…SECURE_AUTH_SALTblock) with fresh ones from the WordPress salt generator — this invalidates every existing login cookie, including the attacker's. - Check the admin users list (Users → All Users) and delete any account you don't recognise. Also check for hidden admins later in the database if the site was deeply compromised.
- Put the site into maintenance mode if it's actively redirecting visitors — a temporary 'back soon' page is far better than sending your customers to a scam site.
Step 3: Take a forensic backup, then scan
Before changing anything, take a full backup of the site *as it is*. That sounds backwards, but if cleaning goes wrong you can return to this exact state, and the backup preserves evidence of how they got in. Then scan with a reputable security plugin — Wordfence or Sucuri — from a fresh install if possible. The scan will flag modified core files, injected code in theme/plugin files, and known malware signatures. Pay attention to files the scanner marks as *changed from the original*: injected code often hides inside legitimate plugin files.
Step 4: Clean, or restore a clean backup
You have two routes. Route A — restore: if you have a backup from *before* the infection (check the date against when symptoms started — restoring an already-infected backup is the classic mistake), restore it, then immediately do Step 5's hardening, because the hole they used is still open in that backup. Route B — manual clean: reinstall WordPress core fresh, reinstall clean copies of all plugins and themes from their original sources, and manually inspect what can't be reinstalled — wp-content/uploads (which should contain media, never .php files), wp-config.php, and .htaccess. Custom code must be reviewed line by line. Manual cleaning is slower but it's the only route that proves the backdoors are gone; most professional malware removal work is Route B for exactly that reason.
The step everyone skips: search the database too. Injected spam links and rogue options (especially in wp_options) survive a file-only cleanup and rebuild the infection within days.
Step 5: Get off Google's blocklist
If Google flagged the site, open Search Console → Security & Manual Actions → Security issues — it lists the hacked categories found. Once the site is verifiably clean, request a review from that same screen and describe what you did. Reviews typically take a few days. Also check your host hasn't left the account flagged, and confirm the red browser warning is gone in an incognito window.
Step 6: Harden, so this is the last time
- Update everything — core, plugins, themes — and delete every plugin and theme you are not using (inactive code can still be exploited).
- Turn on two-factor authentication for admin accounts and limit login attempts.
- Install a firewall/security plugin and keep its scanner running weekly.
- Set up automatic off-site backups — a backup stored on the same server is not a backup strategy.
- Check file permissions (files 644, folders 755) and disable PHP execution in
wp-content/uploads.
If this feels like a lot while your site is actively harming visitors, that's because it is — a hacked site is the one problem where professional help pays for itself in hours saved. My malware removal service covers the full sequence above including the blocklist review, and the care plan exists so the next attempt gets stopped at the door instead.
Frequently Asked Questions
How did my WordPress site get hacked?
Most commonly through an outdated plugin or theme with a known vulnerability, a weak or reused admin password, or an insecure hosting setup. Attackers scan the whole internet for known holes automatically — small sites are targeted just as often as big ones, because the process is automated.
Can a hacked WordPress site be fully cleaned?
Yes, in the overwhelming majority of cases. A thorough clean means fresh core and plugin files, a database inspection, backdoor removal, credential resets and hardening — not just deleting the one file a scanner flagged.
How long does hack recovery take?
A straightforward cleanup is usually completed within 24 hours. Google blocklist reviews add a few days before warnings disappear. Deep or repeated infections take longer because the entry point has to be found, not just the malware.
Rather not fight this error yourself?
Send me the error message and what changed before it appeared. Most WordPress faults are diagnosed the same day — you approve the fixed price before any repair starts.
Get WordPress Troubleshooting HelpWordPress Site Maintenance & Support for $75/m
Stop worrying about updates, hacks and downtime. I keep your WordPress site fast, secure and backed up — so you can focus on your business.
- Weekly core, theme & plugin updates
- Daily backups & uptime monitoring
- Malware scans & security hardening
- Priority fixes for errors & small tasks
More WordPress Guides
How to Fix 'Error Establishing a Database Connection' in WordPress
Your site is down and WordPress can't reach its database. Work through the causes in order — credentials, server, corruption — and get back online without losing data.
Read the guideWordPress Critical Error: What 'There Has Been a Critical Error on This Website' Means — and How to Fix It
The critical error message hides a specific PHP fault behind a vague sentence. Here's how to use recovery mode and debug logs to find the exact plugin, theme or PHP issue causing it.
Read the guideWordPress Site Broken After an Update? Do This First
The update finished and now something's wrong — layout shattered, a feature dead, or a full error screen. The order you do things in decides whether it's a 10-minute fix or a lost day.
Read the guideHow Much Does WordPress Maintenance Cost? A Realistic 2026 Guide
Prices for WordPress maintenance range from free (your own evenings) to agency retainers. Here's what each price band really includes — and which one a small business actually needs.
Read the guideWhy Is My WordPress Site So Slow? 9 Causes and How to Fix Each One
'WordPress is slow' is almost never the real diagnosis. Work through the nine causes that account for nearly every slow site, in the order they usually matter.
Read the guide