How to Recover a Hacked WordPress Site (Step by Step)
In this guide
- First signs your WordPress site is hacked
- Step 1: stop the damage
- Step 2: find how they got in
- Step 3: scan and clean the infection
- Step 4: update everything and reset access
- Step 5: check the hidden places
- Step 6: lock it down so it does not happen again
- When to hire help
- The bottom line: hacked WordPress recovery
Finding out your WordPress site has been hacked is stressful, but it is fixable. Hacked WordPress recovery follows a clear order: stop the damage, find how the attacker got in, clean the infection, and then lock the site down so it does not happen again. How long it takes depends on the infection and whether you have a clean backup — some sites are back within hours, others take days. This guide walks through each step in plain language.
First signs your WordPress site is hacked
You may not notice a hack at first. Common signs include: your site redirects visitors to strange websites, Google shows a "This site may be hacked" warning, new admin users appear that you did not create, unfamiliar links or spam pages show up in search results, your site suddenly runs very slowly, or your host suspends your account for sending spam. If you see any of these, treat the site as hacked and start the steps below.
Step 1: stop the damage
Before anything else, limit what the attacker can do. Put the site into maintenance mode so visitors do not land on hacked pages — many security plugins and hosts offer a one-click maintenance mode. Then change your passwords from a clean device: your WordPress admin password, your hosting account password, your database password, and your FTP password. Do this from a computer you trust, not from a shared or infected machine. You will change them again after cleaning (Step 4), because passwords changed while malware is still present may already be compromised.
Next, tell your hosting provider. Hosts deal with hacked sites every day, and many will scan your account, tell you which files were changed, and sometimes restore a clean backup for you. They can also tell you whether other sites on the same account were affected.
Step 2: find how they got in
Cleaning without finding the entry point is pointless — the attacker will simply come back. The usual entry points are an outdated plugin or theme with a known weakness, a weak admin password, a compromised admin computer, or a nulled (pirated) plugin or theme that contained malware from the start.
Check your site's file modification dates: files changed recently, especially in folders you rarely touch, are suspects. Check for new admin users under Users in your dashboard, and check your plugins list for anything you did not install. A security plugin scan (below) will flag most of these for you.
Step 3: scan and clean the infection
Install a security plugin and run a full scan. Wordfence and Sucuri are the two best-known options, but their free versions are not the same tool. Wordfence's free plugin scans the files on your server and compares WordPress core, plugin, and theme files against clean copies — that is the scan to start with. Sucuri's free plugin is different: it mainly checks your public pages from the outside (its SiteCheck scanner) and watches for changed files; its full server-side scanning and cleanup are paid. Do not assume the two free versions do the same job.
There are two ways to clean the site:
- Restore from a clean backup (best option). If you have a backup from before the hack, restoring it removes the infection in one step. Restore the files and the database, then change all passwords again. Only use a backup you are confident predates the hack.
- Clean the files manually. If there is no clean backup, delete the infected files the scan flagged, reinstall WordPress core, and reinstall every plugin and theme from their official sources. Do not try to edit infected files by hand unless you know exactly what the clean version looks like — reinstalling is safer.
After cleaning, run the scan again. A clean scan is a good sign, but it does not prove every trace of malware is gone — scanners can miss well-hidden backdoors, so keep watching the site and check the hidden places in Step 5.
Step 4: update everything and reset access
With the site clean, close the hole the attacker used. Update WordPress core, every plugin, and every theme. Delete any plugin or theme you do not use — unused code is still code an attacker can exploit. Remove any admin users you do not recognise, and reset the password of every remaining user. Reset them again even if you already changed them in Step 1: the attacker may have captured the new passwords while a backdoor was still in place, or stolen login sessions that stay valid until they are reset.
Also reset your WordPress security keys and salts. These are the secret values in your wp-config.php file that protect login cookies. Resetting them logs everyone out, including anyone still holding a stolen session. Your host or a security plugin can do this for you; if you edit wp-config.php yourself, keep a copy of the original file first.
Step 5: check the hidden places
Attackers hide things where owners rarely look. Check these four spots:
- .htaccess — a hacked .htaccess file can redirect visitors or block you from your own admin area. Compare it against a clean WordPress .htaccess or regenerate it from your dashboard's permalink settings.
- wp-config.php — look for unfamiliar code at the top or bottom of the file.
- Scheduled tasks and cron jobs — a hidden task can re-infect the site on a schedule. Your host can list them.
- Google Search Console — check the Security Issues section. If Google flagged the site, it will show the problem pages, and you can request a review once the site is clean.
Step 6: lock it down so it does not happen again
Recovery is only half the job. Set up the habits that keep a site safe:
- Automatic backups. Schedule daily or weekly backups to a place outside your hosting account, and test restoring one occasionally — a backup you have never tested is a guess, not a safety net.
- Automatic updates. Turn on automatic updates for WordPress core and for plugins you trust. Most hacks exploit weaknesses that were already fixed in an update the owner never installed.
- Two-factor authentication. Add 2FA to your WordPress admin login and your hosting account, so a stolen password alone is not enough.
- Strong, unique passwords. Use a password manager and a different password for every account.
- Only official plugins and themes. Never install nulled or pirated copies — they are a common way malware gets in.
- Limit login attempts. A plugin that limits failed logins blocks the automated password-guessing that runs against WordPress sites all day.
Tip: if your site was hacked once, assume the attacker knows your domain and will try again. The cheapest protection is boring and regular: updates, backups, and 2FA, every week, without fail.
When to hire help
Most site owners can follow the steps above. Hire a professional if the infection keeps coming back after cleaning, if the site handles customer payments or personal data, or if you are not comfortable editing files and the database. WordPress malware removal services exist for exactly this situation; check reviews and get a clear price before handing over access.
The bottom line: hacked WordPress recovery
Hacked WordPress recovery is a sequence, not a single fix: stop the damage, find the entry point, clean or restore, update everything, check the hidden places, and then set up backups and 2FA. Do it in that order and the site has a much better chance of staying clean — but no set of steps can guarantee a site will never be hacked again.
Earn
Zohaib Faisal is the founder and editor of EarnDesk — a freelancer and website builder based in Lahore, Pakistan, with 15+ professional certificates.