All articles Maintenance

WordPress Malware Removal: How to Scan and Clean Your Site Step by Step (2026)

How to scan a WordPress site for malware, where malicious code hides, how to remove it step by step and how to stop it from coming back.

WP Beekeeper Team · 8 min read
Laptop with a magnifying glass finding a bug and a broom sweeping it away: removing malware from WordPress

Your browser warns visitors about your site, Google shows “This site may be hacked”, or your host has suspended your account for malware. Somewhere in your WordPress files or database there is code that should not be there, and it has to go, completely, or it will be back within days.

This guide focuses on the cleanup itself: how to scan a WordPress site for malware, where malicious code usually hides, how to remove it step by step and how to make sure it does not return. If you first want to understand the signs and the first hour after a hack, start with our guide on what to do if your WordPress site is hacked.

Key takeaways

  • Malware rarely sits in one file. It hides in plugins, themes, the uploads folder, .htaccess, wp-config.php and the database, often in several places at once.
  • Scan from the outside and the inside: a remote scanner sees what visitors see, a scanner on the server finds hidden files.
  • Before you clean anything, save a copy of the infected site and change every password.
  • Replace WordPress core, plugins and themes with fresh copies instead of trying to repair infected files.
  • Find out how the attacker got in. If you only remove the symptoms, the same gap lets them back in.
  • After the cleanup, ask Google for a review if your site was flagged, and harden the site.

Signs that your WordPress site has malware

  • Visitors are redirected to spam, gambling or pharma sites, often only on mobile or only when they come from Google.
  • Google shows a warning in search results or Search Console reports security issues.
  • Your browser or antivirus software blocks the site.
  • Search results for your domain show pages you never created, often in Japanese or with product spam.
  • Unknown administrator accounts, plugins or files appear.
  • The site is suddenly slow, sends spam emails or your host reports unusual load.
  • Your host has suspended the account or sent a malware report.

Some infections are built to stay invisible to the site owner. They only show spam to search engines or to visitors who are not logged in. If you see nothing but Google does, check with a remote scanner and the URL inspection in Search Console.

Common types of WordPress malware

TypeWhat it doesWhere it usually hides
Spam injection (SEO spam)Adds hidden links or whole spam pages for search enginesDatabase (posts, options), theme files, new PHP files
Malicious redirectsSends visitors to other sites.htaccess, JavaScript in the database, header.php, plugin files
BackdoorsGive the attacker access again laterFiles in wp-content/uploads, fake plugins, mu-plugins, modified core files
Fake admin usersLet the attacker log in normallyUsers table in the database
Phishing pagesHost fake bank or login pages on your domainNew folders in the web root or in uploads
Crypto miners and spam mailersUse your server’s resourcesPHP files in uploads or temp folders, cron jobs

Step 1: Scan from the outside and the inside

Start with a remote scan, which checks your pages the way a visitor or search engine sees them. Free options include Sucuri SiteCheck and VirusTotal. They find visible injections, redirects and blacklist entries, but they cannot see files on your server.

Then scan on the server. A security plugin with a malware scanner compares your WordPress files with the official versions and searches for known malicious code. Many hosts also offer malware scans in the hosting panel. If you have SSH access, two commands find a lot of typical malware quickly:

# PHP files in the uploads folder (there should be none)
find wp-content/uploads -name "*.php"

# Typical obfuscated code
grep -rl --include=*.php "eval(base64_decode" .

A hit is not always malware, but every result is worth a look. Note every file you find, with its path and date.

Step 2: Secure the site before you clean

  • Save a copy of the infected site, files and database. You will need it to find out what happened, and it protects you if something goes wrong during the cleanup.
  • Put the site into maintenance mode if it is actively harming visitors, ideally with a 503 status code.
  • Change all passwords: WordPress users, hosting panel, SFTP/FTP, database and the email account linked to the admin user.
  • Check the user list and delete administrators you do not know.

Step 3: Replace instead of repairing

Trying to clean infected files line by line is slow and error-prone. It is far safer to replace everything that can be replaced with fresh, official copies:

  • WordPress core: download the same version from wordpress.org and replace the wp-admin and wp-includes folders and the root files, except wp-config.php. The official WordPress FAQ for hacked sites recommends doing this via SFTP rather than with the reinstall button in the dashboard, which can leave injected files in place.
  • Plugins and themes: delete each folder and install a fresh copy from WordPress.org or the developer. Remove everything you do not use.
  • Premium or custom themes: download a clean copy from the developer or restore it from your version control. Compare custom code carefully.

Step 4: Clean what cannot be replaced

Some parts of your site are unique and have to be checked by hand:

  • wp-config.php: compare it with wp-config-sample.php. Look for code that does not belong, for example long encoded strings or includes of unknown files. Then generate new security keys.
  • .htaccess: look for redirects you did not add. If in doubt, replace it with the WordPress default and add your own rules again.
  • wp-content/uploads: it should only contain media. Delete every PHP file and every unknown folder.
  • wp-content/mu-plugins: “must-use” plugins load automatically and are a popular hiding place. Delete anything you did not put there.
  • Database: search posts, options and widgets for <script, eval(, base64 and unknown URLs. Check the users table and the scheduled tasks (cron).

Step 5: Find the way in and close it

Every infection has a cause. The most common ones are an outdated or abandoned plugin with a known vulnerability, a stolen or weak password, a nulled premium plugin or another infected site on the same hosting account. Check the dates of the first malicious files and compare them with your server logs, plugin updates and logins. Then close the gap: update or remove the plugin, enforce new passwords and two-factor authentication, and clean other sites on the same account too.

Step 6: Check, request a review and monitor

  • Scan the site again from the outside and the inside.
  • Check your main pages, forms and checkout.
  • If Google flagged your site, request a review in Search Console under Security issues. Google describes the process in its guide How do I know if my site was hacked?.
  • If your host suspended the account, send them your cleanup report.
  • Keep monitoring the site closely for the next weeks. Reinfections usually happen fast if a backdoor was missed.

When to call in a professional

Cleaning malware yourself is possible if you are comfortable with SFTP, the database and reading PHP. It is a good moment to get help if the site is a shop or handles customer data, if the infection keeps coming back, if your host has suspended the account, or if you simply cannot afford the site being down while you learn. Our hacked site help starts from 399 euros, the same day, seven days a week, and includes finding the way in.

How to keep malware out

  • Keep plugins, themes and core updated, and remove what you do not use.
  • Only install software from WordPress.org or the developer, never nulled plugins.
  • Use unique passwords and two-factor authentication for every admin.
  • Disable the file editor with DISALLOW_FILE_EDIT.
  • Keep tested backups outside the server.
  • Monitor the site, so the next problem is found in hours, not weeks.

Our WordPress security checklist covers each of these in detail.

Want a second pair of eyes?Our Security Audit checks your site for malware and reviews user accounts, file permissions and login hardening. One clear report, fixed price from 79 euros.

Security Audit →

Sources and further reading

Frequently asked questions

How do I check my WordPress site for malware?

Combine a remote scanner such as Sucuri SiteCheck or VirusTotal, which checks what visitors see, with a scanner on the server, such as a security plugin or your host’s malware scan, which compares your files with the official versions and finds hidden code.

Can I remove WordPress malware myself?

Yes, if you are comfortable with SFTP, the database and PHP. Replace core, plugins and themes with fresh copies, clean wp-config.php, .htaccess, the uploads folder and the database, change all passwords and close the gap the attacker used.

Is a security plugin enough to remove malware?

A security plugin can find and often remove known malware, but it can miss backdoors and database injections. Always replace core, plugins and themes with clean copies and check the parts that cannot be replaced.

Why does the malware keep coming back?

Usually because a backdoor was missed or the way in is still open, for example an outdated plugin, a stolen password or another infected site on the same hosting account.

How do I remove the Google warning after cleaning?

Request a review in Google Search Console under Security issues once the site is clean. Google checks the site again and removes the warning if no malware is found.

Should I restore a backup instead of cleaning?

A clean backup from before the infection is often the fastest way back. But you still have to close the gap the attacker used, and you may lose changes made since the backup.

Conclusion

Removing WordPress malware properly means more than deleting the file a scanner found. Scan from outside and inside, secure the site, replace what can be replaced, clean what cannot, find the way in and close it, then check and monitor. Done this way, the cleanup is a one-off event instead of the start of a cycle.

Keep your WordPress site clean.A full backup before every update, updates in the right order, a visual check of every page and uptime monitoring every five minutes. Try WP Beekeeper free for 14 days, no credit card needed.

Start free trial →