Home/Blog/How to Clean a Hacked WordPress Site in 2026

How to Clean a Hacked WordPress Site in 2026

WordPress security shield cleaning a hacked website dashboard

Finding out that your WordPress site has been hacked is stressful, but it is also far more common — and far more fixable — than most site owners realise. Hackers rarely target one site by hand. Automated bots scan millions of WordPress sites every day, looking for one outdated plugin, one weak password, or one missing update to slip through. If you know how to clean a hacked WordPress site properly, you can recover without losing your content, your rankings, or your visitors’ trust.

This guide walks you through the full cleanup process in 2026: how to spot a hack, lock attackers out, remove malware, close the hole they used, and stop the same attack from happening again. Work through the steps in order, and do not skip the password changes at the end — most reinfections happen because the entry point was never closed.

Signs Your WordPress Site Has Been Hacked

A hack is not always obvious. Sometimes the damage is visible, such as defaced pages or strange pop-ups, but often it runs quietly in the background, redirecting search traffic or sending spam. Watch for these warning signs:

  • Unknown administrator accounts, or posts and pages you did not create.
  • Visitors redirected to spam, gambling, or phishing sites, especially from search results.
  • Google Safe Browsing or Search Console warnings, or your site flagged as dangerous.
  • A sudden traffic drop, new files in your uploads folder, or code you do not recognise in theme files.
  • Your host suspending your account, or emails sent from your domain that you never wrote.

Step 1: Back Up the Infected Site and Go Into Maintenance Mode

Before you delete anything, take a full backup of the infected files and database and store it somewhere safe, away from your live site. This copy is evidence: if cleanup goes wrong, you can compare files, and a security professional can use it to trace how the attacker got in. Then put the site into maintenance mode so visitors — and search engines — do not see spam or malicious redirects while you work.

Step 2: Change Every Password and Remove Unknown Admins

Assume every password connected to the site is known to the attacker. Change them all: WordPress administrator accounts, your hosting control panel, SFTP or FTP, the database user, and the email account linked to the site. Delete any administrator or user account you do not recognise, then replace the WordPress security keys and salts in wp-config.php, which logs out every session — including any session the attacker still has open. Turn on two-factor authentication for every administrator account at the same time, so a stolen password alone is never enough again.

Step 3: Scan for Malware and Hunt for Backdoors

Run a full malware scan with a reputable security plugin such as Wordfence or Sucuri, and check the scan results file by file. Do not just delete what the scanner flags and stop there: modern malware hides in several places at once, and backdoors are designed to survive a simple cleanup. Look for suspicious PHP files in the uploads folder, odd code in functions.php and .htaccess, and files using eval or encoded base64 strings. If you are unsure whether a file is legitimate, compare it with a fresh copy from WordPress.org or the plugin author — never guess and delete core files blindly.

Restoring a hacked WordPress site from a clean backup behind a security shield

Step 4: Reinstall Clean Copies of Core, Themes, and Plugins

The safest way to be sure your code is clean is to reinstall it. Replace WordPress core files with a fresh download, reinstall themes and plugins from their official sources, and delete any plugin or theme you no longer use — unused code is a favourite hiding place for malware. Keep only plugins from trusted authors, update everything to the latest version, and remove nulled or pirated plugins entirely: they are one of the most common sources of hidden backdoors. For more on choosing safe extensions, see our WordPress plugins guides.

Step 5: Close the Hole and Harden the Site

Cleaning malware without fixing the entry point guarantees a second hack. Work out how the attacker got in — an outdated plugin is the most common cause, followed by weak credentials and exposed login pages — and fix that first. Then harden the site: add define(‘DISALLOW_FILE_EDIT’, true); to wp-config.php so code cannot be edited from the dashboard, set file permissions to 644 for files and 755 for directories, disable XML-RPC if you do not need it, limit login attempts, and put a web application firewall in front of the site. A firewall blocks known attack patterns before they reach WordPress, which is why it pairs so well with regular malware scanning.

Step 6: Restore From a Clean Backup When Cleanup Is Too Messy

If the infection is widespread, or you cannot be sure every backdoor is gone, restoring from a known-clean backup taken before the hack is often faster and safer than manual cleanup. Restore the files and database, then immediately update everything, change all passwords again, and rescan. Never restore a backup that was taken after the infection started — you would simply restore the malware with it. If you have no clean backup, or the site keeps getting reinfected, this is the point to hand the job to a professional cleanup service rather than spending days learning malware forensics.

Step 7: Request a Review and Monitor Closely

Once the site is clean, scan it again with an external tool such as Sucuri SiteCheck, check Search Console for remaining warnings, and request a review from Google if your site was flagged. Then monitor for at least a few weeks: watch for new unknown users, unexpected file changes, and traffic anomalies. File-integrity monitoring and login alerts turn a future attack from a silent infection into a warning you see within hours, not months.

How to Prevent the Next Hack

Prevention is a short, repeatable routine: update core, themes, and plugins promptly; use strong, unique passwords with two-factor authentication; give each user the lowest role they need; keep a firewall and malware scanner active; and keep automated, genuinely off-site backups that you have actually tested restoring. Do those five things consistently and your site is safer than the large majority of WordPress sites online. For broader site health, explore our free website tools and latest blog guides, and if you are planning a redesign after cleanup, browse our WordPress themes guides.

Conclusion

A hacked WordPress site feels like a disaster, but it is a recoverable one. Back up first, lock down every login, remove the malware and its backdoors, reinstall clean code, close the entry point, and then monitor. The sites that get hacked twice are almost always the ones that cleaned the visible spam but left the same weak password, outdated plugin, or open door in place. Fix the cause, not just the symptom, and your site comes back stronger than before.