PROTECT MY WP

How to Remove Malware From a WordPress Site

By 6 min read

If your WordPress site is infected, the instinct is to start deleting things at random. Resist it. Malware removal that works is a calm, ordered process, and malware removal that fails is usually the panicked version that missed the way back in. This post is the sequence I follow to clean an infected WordPress site, why a single plugin scan rarely finishes the job, and the step most people skip that guarantees the infection comes back.

If you are not yet sure the site is compromised, I have written separately on the signs your WordPress site is hacked. If you already know it is, start here. For the wider recovery picture beyond the malware itself, from taking the site offline to closing the gap the attacker used, see how to recover a hacked WordPress site.


First, do not clean a live compromised site in place

The temptation is to start deleting suspicious files on the live server while the site is still up. Two reasons not to.

First, an attacker who still has access can reinfect faster than you can clean. You will be chasing files that reappear behind you. Second, a compromised site can be actively serving malware to visitors or being used to attack others, so leaving it up prolongs the damage and can get you blocklisted.

Take the site offline or into maintenance mode first. Then work on a copy, or work methodically with the understanding that until you have closed the entry point, cleaning is temporary.


Take a backup before you touch anything

This sounds strange when the site is infected, but do it anyway. Back up the current state, database and files, before you start cleaning.

You are not backing it up to restore it. You are backing it up because cleaning is destructive, mistakes happen, and a copy of the "known bad" state lets you compare, recover a file you deleted too eagerly, and investigate how the compromise happened after the emergency is over. Label it clearly as infected so nobody restores it by accident.


The removal process, in order

Malware removal is a sequence, not a single action. Work through it in order.


Close the way in, or it all comes back

This is the step people skip, and skipping it is why "I cleaned it and it got reinfected" is such a common story.

Cleaning removes the malware. It does not remove the vulnerability that let the malware in. If you clean the site but leave an outdated plugin with a known exploit, a weak admin password, or a backdoor you missed, the site is reinfected within days, sometimes hours, and now you are doing the whole job again with less patience.

So before you bring the site back:


When to stop and call someone

Be honest with yourself about the point of diminishing returns. If the site keeps getting reinfected after you have cleaned it, if you cannot find the backdoor, or if the site handles customer data or payments, a professional malware removal service like Wordfence Care or Sucuri is money well spent. There is no shame in it. A specialist who does this daily will find the file you cannot, and the cost is small next to a site that stays infected.


The removal checklist

  1. Take the site offline or into maintenance mode.
  2. Back up the current infected state and label it clearly.
  3. Scan with a reputable tool to understand the scope.
  4. Reinstall core, plugins, and themes from official clean sources.
  5. Manually check uploads, mu-plugins, .htaccess or nginx config, and wp_options.
  6. Find and remove the backdoor. Treat any PHP file in uploads as hostile.
  7. Delete every unrecognised admin account.
  8. Update everything to current versions.
  9. Reset all passwords and regenerate wp-config salts.
  10. Only then bring the site back, and monitor it closely for 48 hours.

Where this fits

The Protect My WP handbook covers this from both ends. Chapter 10 covers the monitoring and file integrity checks that catch a compromise early, while the incident-response material walks through the full clean-and-recover sequence in more depth than a blog post allows. The best malware removal is the one you never have to do, and most of this book is about making that the outcome.

If you have cleaned a site once and never want to do it again, the book is where the prevention lives.

Get the book for £19.

More on this topic

Want to go deeper?

The first chapter of Protect My WP is free. Start with the foreword, then read Chapter 1 on hosting and server security. There is also a shorter guide that walks the same ground faster if you want the shape of the book first.