Full disclosure: Must-Have Security is our own plugin, and it is the first of the three methods below. We have tried to keep the other two just as complete — the manual route and the Claude Code route both work with no plugin from us at all — so you can pick the one that fits your situation, not ours.

You logged in and something is wrong. Google is showing a red “this site may be hacked” warning under your result, or spammy Japanese keywords appear in Search Console, or visitors land on a pill-selling page that you never made. Maybe there is a new administrator account you did not create, or your host emailed you about malware. A hacked WordPress site is a bad afternoon — but it is a fixable one, and the sooner you act, the less damage the attacker can do.

This guide gives you three complete ways to clean an infected WordPress site, from fastest to most hands-on. Whichever you choose, the shape of the job is the same: find the malicious files, remove them, put clean code back, and close the door the attacker came through so they cannot walk straight back in. Work on a copy or with a fresh backup if you can — cleanup occasionally breaks a fragile site, and you want a way back.

First, confirm it is actually hacked

Not every problem is malware. Before you start deleting things, look for the tell-tale signs of a real compromise:

  • Unknown files that can run code — a .php file inside wp-content/uploads (nothing there should ever execute), or core files that no longer match the official WordPress release.
  • Admin accounts you did not create, or your own account’s email quietly changed.
  • Redirects and injected content — visitors (especially from Google) bounce to another site, or you see spam links in your pages’ source that are hidden from logged-in users.
  • Search Console or your host flags malware, or antivirus blocks your own site.
  • Scheduled tasks nobody added and outbound connections to addresses you do not recognise.

If you see one or more of these, you have a cleanup to do. Here is how — pick a tab.

How to clean a hacked WordPress site: 3 ways

The three tabs below are three routes to the same clean site. The first uses our plugin and is the fastest for most people. The second is the full manual method — more work, total control, no plugin needed. The third points an AI coding agent at your server over SSH. Read the one that fits you.

Whichever route you took: close the door

Removing the malware is only half the job. If you do not fix how the attacker got in, and revoke what they took, you will be cleaning the same site again next week. Do all of these regardless of which method you used:

  1. Update everything. WordPress core, every plugin, every theme. The overwhelming majority of hacks come through a known vulnerability in outdated code, not a clever zero-day.
  2. Delete what you do not use. An inactive plugin is still code on disk that can be exploited. Remove plugins and themes you are not running, especially nulled or abandoned ones.
  3. Rotate every secret. Change all administrator passwords, shuffle the security keys and salts in wp-config.php (this logs everyone out and kills any stolen session cookies), and change the database password and your hosting/FTP passwords.
  4. Audit your users. Delete accounts you did not create, and turn on two-factor authentication so a stolen password alone is not enough. Our own guide to TOTP two-factor in Must-Have Tweaks covers the fit, and temporary admin access is a safer way to let a helper in during cleanup.
  5. Ask Google to take another look. If your site was flagged, use Search Console’s Security Issues report to request a review once you are clean.
  6. Get real backups in place. The single thing that turns the next incident from a crisis into a five-minute restore is a recent, off-site, tested backup. See our 3-2-1 backup strategy for WordPress and why encrypted backups matter.

How do WordPress sites get hacked in the first place?

Almost never through a password guessed by brute force, and almost never through WordPress core itself. In practice the entry point is one of three things: a vulnerable plugin or theme (by a wide margin the most common — an out-of-date component with a known flaw that lets an attacker upload a file or run code), a stolen or reused credential (an admin password that leaked in a breach elsewhere), or a nulled/pirated plugin that shipped with a backdoor already inside it.

Once in, the attacker’s first move is almost always to write a small PHP file — a “web shell” — somewhere writable, often disguised as a cache or config file in wp-content/uploads, and to inject a loader into a legitimate file so it survives. That is why cleanup is not just “delete the bad file”: you have to find every copy, restore the files they tampered with, and take away the ability to write new ones. It is also the idea behind the first method above — if code simply cannot be written to your site without your approval, re-infection has nowhere to land. You can read the vendor-neutral background in our roundup of WordPress security approaches for 2026.

Frequently asked questions

Can I clean a hacked WordPress site for free?

Yes. The manual method and the Claude Code method both cost nothing but your time (Claude Code is a paid tool, but you can do the exact same steps by hand). What you cannot buy back is the time — the manual route is genuinely fiddly, and one missed backdoor means the infection returns. A scanner shortens the “find every copy” part, which is where manual cleanups usually fail.

Should I just delete the whole site and restore a backup?

If you have a clean backup from before the infection, restoring it is often the fastest and safest option — but only if you also patch the vulnerability that let them in, or they will re-hack the restored copy. The catch is knowing when the site was clean; many infections sit quietly for weeks. If your only backups are recent, they may already contain the malware.

How do I know I got all of it?

Re-run the check that first found the problem and make sure it comes back clean: wp core verify-checksums should pass, a fresh scan should show zero findings, and the symptoms (redirects, warnings, spam) should be gone. Then keep watching for a week — re-infection usually shows up within days if you missed a backdoor or left the entry point open.

Is a scanner enough on its own?

A scanner finds and removes what is already there, which is exactly what you want during cleanup. What it does not do by itself is stop the next file from being written. That is why Must-Have Security pairs the scanner with a write-protection layer: cleaning is reactive, and blocking new code is what keeps the site clean afterwards.

Do I need to tell my visitors?

If the site handled personal data and there is any chance it was exposed, you may have a legal duty to notify — check your local rules (GDPR and similar). At a minimum, if customer accounts exist, force a password reset once you are clean.

The takeaway

Cleaning a hacked WordPress site comes down to four moves: find the malicious code, remove it, restore clean files, and close the way in. A scanner like Must-Have Security does the finding and removing for you and — just as importantly — stops new malware from being written, so the cleanup holds. The manual method gives you total control for the price of care and patience. And an AI agent like Claude Code can drive the whole audit over SSH while you watch. Pick the one that matches your comfort level, do the “close the door” checklist without skipping it, and get a real backup in place before the next time.

Related reading: WordPress security plugins compared for 2026, the 3-2-1 backup strategy, and WordPress login and 2FA options compared.