WordPress

Cleaning a Hacked WordPress Site: A Calm, Step-by-Step Recovery

S
Shuvonkor Pramanik · 3 December 2026 · 7 min read
Cleaning a Hacked WordPress Site: A Calm, Step-by-Step Recovery

The call usually comes in one of two forms. Either Chrome is showing a red "Deceptive site ahead" warning, or a patient rings the clinic to ask why its website is advertising casino bonuses in Bangla and Indonesian. The usual reaction is to delete the strange files, change the admin password and hope. That wipes out the evidence of how the attacker got in and leaves their other ways in open. A hacked WordPress site can almost always be recovered, but what saves it is the right order, not speed. Here is that order.

First hour: contain the damage and keep a copy

Before you clean anything, stop the site harming visitors, and keep the evidence:

  • Restrict public access. Turn on a maintenance page, or ask your host (Hostinger, a cPanel reseller, whoever it is) to block public traffic for now. If you use Cloudflare, a firewall rule that only lets in your own IP address does the same job in two minutes.
  • Snapshot the infected site. Download every file and export the database exactly as they are now. It feels odd to back up malware, but this copy is how you will find the way in, and it is your fallback if the cleanup goes wrong. Label it clearly so nobody restores it by mistake.
  • Scan every admin's computer. If a staff laptop has a password-stealing infection, the site will be hacked again the day after you clean it. Run a full antivirus scan on every device that has logged in to wp-admin, cPanel or your email.

Investigate before you touch a file

Most failed cleanups come from skipping this step. You need to know how the attacker got in, because that way in has to be closed later. Check these places:

  1. Users. In wp-admin, and directly in the database's users table, look for administrator accounts nobody recognises. Attackers often create one with a name that sounds like a system account.
  2. Recently changed files. In cPanel File Manager or over SFTP, sort by modified date. Infected files tend to share a date, and that date tells you when the break-in happened.
  3. Scheduled tasks. Check the server's cron jobs and WordPress's own scheduled events. Attackers plant tasks that put the malware back after you delete it.
  4. Access logs. Your hosting panel keeps raw access logs. Look at the requests around the earliest infected-file date. They often point straight at the cause: a vulnerable plugin's file being hit, thousands of login attempts, or an upload form used to drop a script.
  5. The plugin list. Look for anything out of date, abandoned, or installed from a "free premium" download site. Nulled copies of paid tools, such as the pirated Elementor Pro builds passed around online, are a very common way in, because they often ship with hidden backdoors.

A security scanner will flag known malware patterns. Treat its report as a list of places to look, not a cleanup: scanners find symptoms, logs find causes.

Clean by replacing code, not by editing it

Deleting infected lines by hand from hundreds of PHP files is how cleanups fail. Malware is designed to hide, and missing even one backdoor means it comes back. Professionals replace the code instead of repairing it:

  1. Download fresh copies of WordPress core, your theme and every plugin, at the same version or newer, from their official sources only.
  2. Delete the whole existing codebase and upload the clean copies. Only two things carry over: the wp-content/uploads folder and the database.
  3. Check the uploads folder for files that should never be there, such as .php, .phtml or files with double extensions like invoice.pdf.php. Uploads should hold images, PDFs and media, and nothing that runs as code.
  4. Search the database for injected script tags, hidden spam links in posts and widgets, strange site URL values, and the rogue admin users you found earlier.
  5. Remove anything nobody can vouch for: unknown plugins, old test installs in subfolders, ZIP files left in the web root. If nobody can say what it is, it does not come back.

If you have a clean backup from before the infection, restoring it and then updating everything is often quicker. The catch is that the backup has to come from before the break-in, not just from before you noticed the symptoms. The two can be weeks apart, which is why the investigation dates matter.

Reset every credential, not just one

Assume the attacker read everything on the server. Reset all of these, with long unique passwords stored in a password manager:

CredentialWhere to change itWhy it matters
Every WordPress userUsers screen; force a reset for staffStolen admin passwords let the attacker walk straight back in
Database passwordHosting panel, then update wp-config.phpwp-config.php is the first file attackers read
Hosting / cPanel loginHost's account area, and enable 2FAGives full control of every site on the account
FTP / SFTP accountsHosting panel; delete unused onesOld developer accounts are often forgotten
WordPress security keys (salts)Replace the keys in wp-config.phpLogs out every existing session, including the attacker's
Email accounts tied to admin usersMail providerPassword-reset links go to these inboxes

While you are in there, turn on two-factor authentication for every administrator. Skipping even one of these resets is how sites get "hacked again" the same week. The attacker never really left, they just logged back in.

Close the door, then prove the site is clean

Update or remove whatever the investigation showed was the way in. Then repair your reputation with the outside world:

  • In Google Search Console, open the Security Issues report and request a review once the site is genuinely clean. If you explain what you fixed, the review is more likely to go through first time.
  • Make sure the injected spam URLs now return a proper 404 or 410 response, so they drop out of Google's index. Resubmit your sitemap.
  • Check whether your domain or server IP has landed on email blacklists. Hacked sites often send spam, and your normal emails may be landing in customers' junk folders.
  • If the site took orders or kept customer accounts, decide honestly what data may have been exposed, reset customer passwords and tell affected people plainly.

Then keep a close eye on the site for two to four weeks. Run weekly scans, turn on file-change alerts and review the admin user list. Failed cleanups almost always show themselves within the first month. A wider technical website audit afterwards will also catch any leftover spam pages or broken redirects that hurt your search visibility.

DIY or bring in help?

An owner comfortable with cPanel can work through this for a simple brochure site over a weekend. Call professionals when money or customer data passes through the site, when the hack returns after your cleanup, or when the host has suspended the account. Cleanup plus hardening should be a fixed, quoted job; as a rough guide, small Dhaka sites often land around ৳5,000–৳20,000, stores more. Ask any vendor: How will you find the way in? Will you replace the core and plugin files or just scan them? Which credentials will you reset? What monitoring comes afterwards? If they only promise to "remove the virus", keep looking.

Prevention costs far less than recovery, which is why ongoing WordPress maintenance and security monitoring usually pays for itself. It also helps to know what your server setup is doing. A plain-English guide to how website hosting works makes it much easier to talk to your host during an incident. If the hack revealed deeper problems, such as a nulled theme, years of skipped updates or no backups, it may be cheaper to rebuild on a clean, maintained foundation than to pay for cleanups twice a year.

FAQ

How long does it take to clean a hacked WordPress site?

A simple infection on a small brochure site usually takes a few hours to a day. A WooCommerce store, a multisite network or a hack that keeps coming back can take several days, plus a few weeks of monitoring. Google's review usually clears within a few days once the site really is clean.

Will a security plugin remove the hack automatically?

It may remove visible malware, but it rarely finds the entry point, hidden backdoors or rogue admins. Use it to find where to look, then replace code and reset credentials.

Why does my site keep getting hacked after cleaning?

Usually one of three things: a backdoor file or scheduled task was missed, a credential such as FTP or the database password was not reset, or the vulnerable plugin is still installed. An infected staff computer is the fourth common cause.

Should I delete everything and start a new site?

Starting fresh can be the right call, but only after you have worked out how the attacker got in. Otherwise you rebuild with the same weak password or the same nulled plugin and get hacked again.

Running WordPress and want it fast, secure and easy to edit?

We build and maintain WordPress and WooCommerce sites, from new builds to rescue jobs on slow or broken sites.

See WordPress care →Get a free quote →

Keep reading