Security · Guide
How to Clean a Hacked WordPress Site Step by Step
Short answer
To clean a hacked WordPress site, isolate it, save a copy of the files and database, scan it, then replace WordPress core, plugin and theme files with fresh copies of the same version. Remove unknown admin users, reset every password and replace the 8 security keys and salts in wp-config.php, then update everything and close the entry point. When scans are clean, ask Google for a review in Search Console.
Key takeaways
- Save a full copy of the infected files and database before you change anything, and label it with the date and the word hacked.
- Replace wp-admin and wp-includes with fresh copies of the same WordPress version, and reinstall plugins and themes from official sources.
- Changing the 4 keys and 4 salts in wp-config.php logs out every user, including an attacker with an active session.
- Change every password a second time after the site is clean, including FTP, hosting, admin and database passwords.
- Ask Google for a review only after every issue is fixed on every page, because most reviews take several days or weeks.
How do you know your WordPress site was hacked?
A hacked site shows changes you did not make, warnings from Google or your host, or new admin users you did not create.
WordPress.org lists clear signs in its hacked-site FAQ, including a Google or Bing blacklist warning, a host that disabled the site, a flag for distributing malware, and antivirus warnings from readers (FAQ My site was hacked).
Other signs are spam pages in search results, redirects to strange sites, and content or links you did not add. Check a search for site:yourdomain.com and look for titles that do not belong to you.
Do not rely on one sign alone. A slow site or a broken page can have a harmless cause, so confirm the problem with a scan before you delete files.
What should you do first after a hack?
Write down what you see, when you noticed it, and what changed recently, then contact your host.
WordPress.org calls documentation the first action after a hack, because it forms the incident report you and any helper will use. Note the symptoms, the time and timezone, and recent changes such as a new plugin or theme edit.
Tell your host the same day. The hack may affect more than one site on shared hosting, and your host can confirm whether it is a hack or a loss of service.
Scan your own computer for malware too. WordPress.org notes that many attacks start on a local computer, where a trojan steals FTP or admin login details.
If customer data, payments, or email may be involved, get professional help now. Cleaning files is not a substitute for advice on data exposure, and a host or security professional can guide the next steps.
How do you isolate the site and save evidence?
Take the site offline for visitors, then save a full copy of the files and database before you change anything.
Isolation stops visitors from reaching malware and stops the attacker from making more changes while you work. Use maintenance mode in your host panel, or ask your host to suspend the site.
Save the copy even though it is infected. WordPress.org recommends one more snapshot before cleaning, so you have a reference if the cleanup fails.
Label the copy with the date and the word hacked, and store it away from the live site. Never restore this copy as a fix, because it still holds the malicious code.
For backup steps you can use later, see our guide on how to back up WordPress.
How do you scan a hacked WordPress site?
Run a remote scan and a server-side scan, because each type sees different things.
A remote scan checks what a visitor or search engine sees. Sucuri SiteCheck is one free remote scanner, and it checks for known malware and blocklist status from outside the server (Sucuri SiteCheck).
A server-side scan checks files on the server, including backdoors and code that never shows in a browser. Sucuri's cleanup guide says the most complete approach uses remote and server-side scanners together (How to Remove Malware and Fix a Hacked WordPress Site).
VirusTotal checks a URL against more than 70 vendors, which helps you see how many blocklists flag the site. Enter the site address on its URL tab and review the detection results (VirusTotal).
Also check Google's Transparency Report for the site's Safe Browsing status. It shows whether Google currently treats the site as unsafe (Safe Browsing site status).
Keep a list of every flagged file, URL, and user account. That list becomes your cleanup checklist, and it helps you find the entry point later.
Should you restore a backup or clean the files by hand?
Restore a clean backup from before the hack if you have one, and clean by hand only if no clean backup exists.
A backup is clean only if it was made before the attacker got in. A site can be compromised days or weeks before anyone notices, so check the backup date against the first sign of trouble.
Restoring is usually the fastest route back, but it does not fix the entry point on its own. You must still update everything, reset passwords, and remove unknown users after the restore.
For the restore steps, see how to restore a backup with UpdraftPlus.
If no clean backup exists, rebuild from fresh copies instead of patching infected files one by one. That work is covered in the next section.
| Option | When to use it | Main risk |
|---|---|---|
| Restore a clean backup | Backup date is before the first sign of the hack | Backup may already hold the hack |
| Clean files by hand | No clean backup exists | A hidden backdoor may be missed |
| Ask a professional | Customer data is involved, or the hack returns | Cost and time to find a helper |
How do you remove malicious code from WordPress files and the database?
Replace WordPress core, plugin, and theme files with fresh copies of the same version, then check the database and key files by hand.
Start with the version you run. Sucuri's guide says to note the version in wp-includes/version.php, then download that same version from WordPress.org.
Replace the /wp-admin and /wp-includes folders with fresh copies. WordPress.org warns that an older or newer version can break the site, so match the version exactly.
Do not use the reinstall button in the dashboard for this step. WordPress.org notes that dashboard installers often only overwrite existing files, while hacks often add new files.
Reinstall each plugin and theme from its official source. Delete the plugin or theme folder first, then install a fresh copy, because a deactivated plugin can still hold malicious code.
Check these files by hand, because WordPress.org names them as common targets:
.htaccessin the site root and in other foldersindex.phpheader.phpandfooter.phpin the themefunctions.phpin the themewp-config.phpfor added code
Look for recently changed files too. Sucuri's guide gives the command find . -type f -mtime -90 to list files changed in the last 90 days, and ls -1tlah | head -10 to show the 10 most recently changed files.
Check the database for spam links, new posts, and strange content in the wp_options table. Search for words from the spam pages, and remove only the entries you can identify as malicious.
If you are not sure whether a file or database entry is safe, stop and ask your host or a security professional. Deleting the wrong file can break the site.
How do you reset passwords and log everyone out?
Change every password, replace the 8 security keys and salts in wp-config.php, and remove admin users you do not recognise.
WordPress.org lists every access point to change: FTP or SFTP, the WordPress admin, the hosting control panel, and the database. Change them for every user with access, not just your own account.
Resetting a password does not end a session an attacker already holds. To end every session at once, replace the keys and salts in wp-config.php with a fresh set.
WordPress developer docs explain that the file holds 4 keys and 4 salts, and changing them invalidates all existing cookies, so every user must log in again (wp-config.php).
Get a fresh set from the WordPress secret-key generator, then paste the 8 lines over the old ones in wp-config.php (WordPress secret-key generator).
Then open “Users” and “All Users” in the dashboard and filter by Administrator. Delete any account you do not recognise, and demote accounts that do not need full admin rights.
Change every password a second time after the site is clean. WordPress.org gives this order for a reason: passwords changed during cleanup may already be known to the attacker.
How do you close the entry point so it does not happen again?
Find how the attacker got in, update everything, remove unused code, and turn on two-factor login for admins.
Forensics means finding the attack route so it cannot be used again. WordPress.org uses that term for this step, and it lists server logs and recently changed files as the main clues.
Ask your host for access logs and login history early, because some hosts keep them only for a short time. Look for the first strange file change, login, or plugin install.
Update WordPress core, every plugin, and every theme to the latest version once the site is clean. WordPress.org notes that older versions are more prone to hacks than newer versions, as of November 2026.
Delete plugins and themes you do not use, including inactive ones. An inactive plugin still has files on the server, and those files can hold a known flaw.
Do not install plugins or themes from unofficial sources. Pirated copies, often called nulled plugins, can carry hidden code, as explained in are nulled WordPress plugins safe.
Set file permissions to 755 for folders and 644 for files, as Sucuri's cleanup guide and the WordPress hardening advice recommend. Never use 777, which lets any process on the server write to the file.
Add a firewall and two-factor login for admin accounts. Wordfence explains that its scan compares core, plugin, and theme files with the official copies and can repair changed files (How to Protect Yourself from WordPress Security Issues).
For firewall setup steps, see how to set up the Wordfence firewall.
How do you ask Google to remove the warning?
Fix every issue on every page, then click “Request Review” in the Security issues report in Google Search Console.
Google's Security issues report lists hacked content, malware and unwanted software, and social engineering, with sample URLs for each issue. A clean report shows a green check mark (Security issues report).
Google says the sample URLs are only a sample, so fix the issue throughout the site, not just on the listed pages. Fixing only some pages will not earn a partial return to search results.
In the review request, explain the exact issue, describe the steps you took to fix it, and document the outcome. Google lists those 3 points as the parts of a good request.
Most reviews take several days or weeks, according to Google. Other Google guidance gives about a day for phishing, a few days for malware, and up to several weeks for hacked spam, with warnings removed within 72 hours after approval, as of November 2026.
Do not send a second request while one is still pending. Google warns that an early request can slow the next review or mark the site as a repeat offender.
| Issue type | Google review time, as of November 2026 |
|---|---|
| Phishing | About a day |
| Malware | A few days |
| Hacked with spam | Up to several weeks |
| After approval | Warnings removed within 72 hours |
What mistakes should you avoid?
Do not delete files before you save a copy, do not restore an infected backup, and do not ask Google for a review before the site is clean.
Cleaning without a saved copy leaves you with no evidence and no way back if a step breaks the site. Keep the infected copy labelled and stored away from the live site.
Restoring a backup made after the hack can put the same malicious code back. Check the backup date against the first sign of trouble before you restore it.
Changing passwords once is not enough. If you skip the second password change after cleanup, an attacker who still had access during the work can log back in.
Do not leave the entry point open. A clean site with an outdated plugin or a stolen password can be hacked again the same way, so update, remove unused code, and check the logs.
If the cost of professional help worries you, read how much it costs to clean a hacked WordPress site before you decide whether to do the work yourself.
Frequently asked questions
How long does it take to clean a hacked WordPress site?
A simple restore from a clean backup can take a few hours, while a manual cleanup can take a day or more, depending on the size of the site and how many files are infected. Google review time is separate: most reviews take several days or weeks, with phishing cases often faster than hacked spam cases. Do not rush the review request, because an early request can slow the next one.
Can I clean a hacked WordPress site myself?
You can do it yourself if you are comfortable with SFTP, file managers and the database, and the hack is limited to a few files. Use fresh copies from official sources, keep a labelled copy of the infected site, and follow the order in this guide. If customer data is involved, or the hack keeps returning, ask your host or a security professional instead.
Should I delete my whole WordPress site and start again?
Deleting everything is rarely needed, and it can destroy content you cannot recover. A clean backup restore or a rebuild from fresh core, plugin and theme files usually works, as long as you also check the database and close the entry point. Keep a copy of the infected site first, so you have evidence and a reference if something goes wrong.
Why does my site keep getting hacked after I clean it?
The most common reason is an open entry point: an outdated plugin or theme, a stolen password, an unknown admin account, or a hidden backdoor file that the cleanup missed. Check the server logs for the first strange change, update everything, remove unused plugins and themes, and change all passwords again after the cleanup is done.
Will Google remove the warning automatically after I clean the site?
No, you must ask for a review in the Security issues report in Google Search Console after every issue is fixed on every page. In the request, explain the exact issue, describe what you did to fix it, and document the outcome. Google will email you when the request is received and again when the review is complete.
Sources
- FAQ My site was hacked WordPress.org
- How to Remove Malware and Fix a Hacked WordPress Site Sucuri
- Security issues report Google Search Console Help
- wp-config.php WordPress Developer Resources
- How to Protect Yourself from WordPress Security Issues and Threats Wordfence
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
