If your WordPress site redirects visitors, shows spam or got flagged by Google, it’s probably infected. Cleaning it is a clear sequence: back up, find everything infected, replace what you can’t trust, then lock the doors.
We planted five common infections on a test site, from a backdoor in uploads to a hidden admin, then found and removed all five. One check found the modified core file in under a second. The hidden admin didn’t show on the Users screen at all.
Signs your WordPress site is hacked
Infections are designed to hide, so the signs are often indirect:
- Visitors (especially on mobile or from Google) get redirected to spam or scam sites.
- Google Search shows spammy titles or foreign-language pages under your domain.
- Browsers or Google show a “This site may be hacked” or “Deceptive site ahead” warning.
- New admin users you didn’t create, or your own password stops working.
- Your host suspends the site or emails about malware or high resource use.
- Unknown files in your uploads folder, or plugins you didn’t install.
- Pages load a script from a domain you don’t recognise.
Some of these only appear to logged-out visitors, which is why owners miss them for weeks.
Common types of WordPress malware
Knowing what you’re dealing with tells you where to look first.
| Type | What you notice | Where it usually hides |
|---|---|---|
| Redirect malware | Visitors sent to scam or spam sites, often only from Google or on mobile | .htaccess, wp-config.php, theme header, options table |
| SEO spam | Spammy or foreign-language pages under your domain in Google | A PHP page generator in uploads or a plugin folder |
| Credit card skimmer | Customers report card fraud after buying | Checkout page scripts, theme footer, options table |
| Backdoor (web shell) | Nothing, until the infection returns | Uploads, mu-plugins, theme and plugin files |
| Rogue admin | Unknown administrators, or none visible but strange changes | Users table, hidden by code |
| Mailer or miner | Host warnings about CPU or outgoing email | Uploads, tmp folders, cron jobs |
Redirect malware is the most common. It usually lives in .htaccess, wp-config.php, the theme’s header or the database options table, and often only fires for logged-out visitors arriving from search engines, so the owner never sees it.
SEO spam creates thousands of pages under your domain, often in another language, to sell knock-off goods. You’ll see them in Google before you see them on the site. They’re often served by a single PHP file that generates pages on the fly.
Credit card skimmers target WooCommerce checkout pages. They add a script that copies card details as customers type. They’re small, often loaded from a lookalike domain, and the most damaging infection on this list.
Backdoors are what bring infections back. A single small PHP file that runs whatever code the attacker sends is enough. Most sites have more than one after a real hack.
Rogue admin accounts give the attacker a normal login, which survives file clean-ups. Hidden ones, like the one in our test, are designed to survive an owner’s check too.
Mailers and miners use your server to send spam email or mine cryptocurrency. The sign is usually a host warning about resource use or email blocklisting.
What we tested
We installed a fresh copy of WordPress 7.1.5 on a test server, then added five harmless samples that mimic real infections. None of the samples could run: each “malicious” line sat inside code that never executes. The point was to see how each one looks to the site owner, and what finds it.
| Sample we planted | Where | What it mimics |
|---|---|---|
| PHP backdoor named like a cache file | A dated folder inside wp-content/uploads | A web shell that runs code sent by the attacker |
| Extra line in a core file | wp-includes/plugin.php | Malware injected into WordPress itself |
| Must-use plugin | wp-content/mu-plugins/ | Code that always runs and isn’t on the Plugins screen |
| Hidden admin account | Database (wp_users) | An attacker’s way back in |
| Spam script in a post | Database (wp_posts) | Injected redirects and spam scripts |
Then we ran each detection step below and timed the clean-up.
| Check | What it found | Time |
|---|---|---|
| Core checksum comparison (3,338 files) | 1 modified file: wp-includes/plugin.php | Under 1 second |
| PHP files in uploads | 1 file: the backdoor | Instant |
| Must-use plugins folder | 1 unknown plugin | Instant |
| Admins in the database vs the Users screen | 2 in the database, 1 on screen | Instant |
Database search for <script | 1 infected post | Instant |
| Pattern search (eval, base64_decode and similar) | 109 files, 106 of them clean core | Under 1 second |

Three lessons from the test:
- Core checksums are the fastest, most precise check. WordPress publishes the expected fingerprint of every core file. Comparing 3,338 files took under a second and flagged exactly one: the file we’d modified.
- Searching for “eval” or “base64_decode” alone is noisy. Our search found 109 PHP files with those patterns. After cleaning, 106 were still there, because a clean WordPress core uses those functions legitimately. Use pattern searches to narrow down, not to decide.
- The Users screen can lie. Our hidden must-use plugin filtered the rogue admin out of the Users list, which showed one administrator. The database showed two.
Before you start: contain the damage
Do these first, in this order:
- Put the site in maintenance mode or ask your host to take it offline, if it’s actively redirecting visitors.
- Change your hosting, SFTP and database passwords from a clean device. If the attacker has those, everything else is wasted.
- Take a full backup of the infected site, files and database. It sounds backwards, but if the clean-up breaks something, you need a copy to recover content from. Our infected backup was a 105 KB database dump and a 35.6 MB archive of files. Label it clearly as infected.
- Check whether you have a clean backup from before the infection. If you do and know when the hack happened, restoring it may be faster. You’ll still need the hardening steps, or it’ll happen again.
Tools you’ll need
You don’t need anything exotic. For our test, we used:
- An SFTP client or your host’s file manager, to delete and upload files.
- A database tool such as phpMyAdmin, which most hosts include, to list users and search content.
- WordPress.org’s published checksums for your version, for comparing core files.
- A fresh copy of WordPress in the same version as your site, from wordpress.org.
- WordPress’s security key generator, to create new keys for wp-config.php.
- A text editor that shows hidden characters and long lines, for checking wp-config.php and .htaccess.
A security plugin with a file scanner adds a useful second opinion, and your host’s own malware scanner can see files a plugin can’t. If you’re comfortable with a command line, your host’s SSH access makes searching files much faster.
How to remove malware from WordPress, step by step
The steps at a glance
-
Step 1 of 10
Back up the infected site
Export the database and download all files, and label the backup as infected. You’ll need it if the clean-up removes something you want to keep.
-
Step 2 of 10
Replace WordPress core files
Download the same WordPress version from wordpress.org. Delete
wp-adminandwp-includes, then upload fresh copies, along with the root PHP files exceptwp-config.php. This removes any injected core code in one move. -
Step 3 of 10
Reinstall plugins and themes from trusted sources
Delete and reinstall every plugin and theme from wordpress.org or the vendor. Delete any you don’t recognise or don’t use. Don’t restore them from the infected backup.
-
Step 4 of 10
Remove backdoors from wp-content
Delete PHP files in uploads, check
mu-pluginsand drop-in files, and review your theme’s recently changed files. In our test, this removed the uploads backdoor and the hidden plugin. -
Step 5 of 10
Remove rogue users
List administrators directly in the database and delete any you don’t recognise, reassigning their content to your account. Then check the Users screen again.
-
Step 6 of 10
Clean the database
Search posts, pages, widgets and the options table for script tags, iframes and unfamiliar domains, and remove the injected code. Take care to remove only the injected part.
-
Step 7 of 10
Reset passwords and security keys
Change every admin password, log out all sessions, and replace the security keys in
wp-config.phpwith new ones from WordPress’s key generator. That invalidates any stolen login cookies. -
Step 8 of 10
Check wp-config.php and .htaccess
Compare them with a clean sample. Remove unfamiliar includes, redirects or long encoded strings.
-
Step 9 of 10
Scan again and verify
Re-run the checksum check, a malware scanner and a logged-out test of the site on mobile. In our test, every check came back clean and the site loaded normally.
-
Step 10 of 10
Harden the site
Add
define( 'DISALLOW_FILE_EDIT', true );towp-config.php, block PHP in uploads, turn on two-factor authentication and set up offsite backups.

How to find infected files without special tools
You don’t need a paid scanner to find most infections, but you do need to know where to look.
Compare core files against official checksums
WordPress.org publishes an MD5 fingerprint for every file in each release. Download the list for your version and language, then compare each file in wp-admin, wp-includes and the root folder. Any mismatch is a modified file, and any extra PHP file in those folders shouldn’t be there.
Many security plugins do this for you. Your host may offer it too. The point is the method: checksums tell you exactly which core files changed, with no guesswork.
Look for PHP files in uploads
The uploads folder should hold images, PDFs and other media. A PHP file in uploads is almost always malicious. In our test, the backdoor was named like a cache file in the current month’s folder, exactly where a real one tends to hide.
Check must-use plugins and drop-ins
The wp-content/mu-plugins folder runs automatically and doesn’t appear on the normal Plugins screen. Attackers like it for that reason. Check it, along with drop-in files directly in wp-content, such as object-cache.php or advanced-cache.php, which should match what your caching setup installed.
Check users in the database, not just the dashboard
Open your database tool (most hosts include phpMyAdmin) and list every user with the administrator role. Compare it with the Users screen. Any account that’s in the database but not on the screen is being hidden, which means there’s also malicious code doing the hiding.
Search the database for injected scripts
Search posts, pages, widgets and options for <script and for unfamiliar domains. In our test, the spam script was added straight to the database, bypassing WordPress’s own filtering, so it only showed up in a database search and in the page source.
Check recently modified files
Sort files by modification date and look at anything changed around the time problems started. Attackers sometimes fake file dates, so treat this as a hint, not proof.
| Location | What to look for |
|---|---|
| wp-admin, wp-includes, root files | Any file that doesn’t match official checksums, or extra PHP files |
| wp-content/uploads | Any .php file |
| wp-content/mu-plugins | Anything you didn’t install |
| wp-content root | Unexpected drop-ins or PHP files |
| Active theme folder | Recently changed functions.php, header.php or footer.php |
| wp-config.php and .htaccess | Unfamiliar includes, redirects or encoded strings |
| Database: users | Administrators you don’t recognise |
| Database: posts and options | Script tags, iframes or unfamiliar domains |
Extra steps for WooCommerce stores
If your site takes payments, a hack is more serious, and the clean-up has extra steps.
- Check checkout pages first. Load the checkout as a logged-out customer, view the page source, and look for scripts from domains you don’t recognise. Skimmers often hide in the theme’s footer, a custom HTML widget or the options table.
- Check payment gateway plugin files against fresh copies from the vendor.
- Tell your payment processor. They can help you work out whether card data was exposed and what you need to do next.
- Consider your customers. If card or personal data may have been taken, you may need to notify customers and regulators. Get advice before you make any public statement.
- Rotate API keys for payment, shipping and email services stored in WordPress, because the attacker may have read them.
If you have several sites on one hosting account
On shared hosting, sites in the same account can usually read each other’s files. If one is infected, assume all of them might be. Clean every site in the account at the same time, or the clean ones get reinfected from the one you missed. Old test sites and forgotten installs in subfolders are common culprits.
Cleaning SEO spam out of Google
Removing spam pages from your server is only half the job. Google may keep showing them for weeks.
- Make sure the spam URLs return a 404 or 410 error. Check a few in a private window. If they still load, the generator file is still there.
- Check your sitemap for URLs you didn’t create, and regenerate it.
- Check Search Console for unknown owners or users. Attackers sometimes verify themselves to submit spam sitemaps. Remove them.
- Use the Removals tool in Search Console for the worst URLs, to hide them from results while Google recrawls.
- Request a review if there’s a security issue listed.
What our test didn’t cover
Our lab used five inert samples on a fresh site. Real infections are messier: obfuscated code, many backdoors, infected plugin files, and malware in places we didn’t plant anything, such as the database’s scheduled tasks or server cron jobs. Treat our results as a demonstration of the method, not a complete list of what to expect. If a real clean-up doesn’t hold, assume there’s something you haven’t found yet.
Should you use a malware scanner plugin?
Yes, as a second opinion. Scanners know thousands of malware signatures that a manual check won’t recognise, and they can watch for changes going forward. Our guide to the best WordPress security plugins compares the main options.
Three cautions:
- A scanner can’t clean what it can’t reach. If the infection has admin access, it can switch off or fool a plugin running on the same site. Run server-side scans from your host too.
- “Clean” doesn’t mean secure. Removing files without fixing how the attacker got in leads to reinfection.
- Install it after you’ve changed passwords. Otherwise the attacker may still be watching.
If you’d rather hand the job over, a malware removal service like Virusdie scans and cleans from the server side. Our Virusdie review covers how it works.
Manual clean-up, plugin or paid service?
There are three ways to get the job done. The right one depends on your skills, your budget and how bad the infection is.
| Route | Cost | Skill needed | Best for |
|---|---|---|---|
| Manual (the steps above) | Free, plus your time | Comfortable with files, SFTP and a database tool | Small sites, obvious infections, recent backups |
| Security plugin scan and repair | Free to paid annual licence | Low to moderate | Finding known malware and repairing core files |
| Professional clean-up service | One-off fee or subscription | None | Stores, repeat infections, no server access |
For a small blog with an obvious infection and a recent backup, the manual route works well, especially with a free scanner as a cross-check. For a store, a site that’s been reinfected, or anyone who doesn’t want to touch a database, a service is money well spent. Many security plugins sit in between: they find and repair common problems, but rely on you for the rest.
Whichever route you take, the hardening steps afterwards are the same, and they’re what stop the next infection.
After the clean-up: request a review
If Google flagged your site, sign in to Google Search Console, open the Security issues report, confirm the problems are fixed, and request a review. Google usually reviews within days. Check other blocklists your security tool reports, and ask your host to lift any suspension.
Then watch the site closely for two weeks. Reinfection within days means a backdoor was missed or the entry point is still open.
How to stop it happening again
Most WordPress hacks come through a few doors. Close them all.
- Update everything. Outdated plugins and themes are the most common way in. Turn on automatic updates for minor releases and trusted plugins.
- Delete what you don’t use. Deactivated plugins and unused themes can still be exploited.
- Turn on two-factor authentication for every admin. Our explainer on two-factor authentication covers the options.
- Use unique, strong passwords for WordPress, hosting, SFTP and the database.
- Disable the file editor. Adding DISALLOW_FILE_EDIT to wp-config.php, as we did, stops anyone with admin access editing theme and plugin code from the dashboard.
- Block PHP in uploads with a server rule. We added an .htaccess rule for Apache; on Nginx, your host can add the equivalent.
- Keep offsite backups on a schedule, and test a restore. See our list of WordPress backup plugins.
- Install a security plugin for login protection, scanning and alerts. Solid Security (formerly iThemes Security) and Jetpack are common choices; our Kadence Security Pro review covers another.
A simple security routine
Most WordPress hacks start with something a few minutes of routine maintenance would have caught. This schedule is enough for most small sites.
| How often | Task |
|---|---|
| Weekly | Apply plugin, theme and core updates; check the security plugin’s alerts |
| Monthly | Review administrator accounts; delete unused plugins and themes; confirm backups ran |
| Every three months | Test restoring a backup to a staging site; review who has hosting and SFTP access |
| After any change of staff or developer | Remove their accounts and change shared passwords |
Put it in your calendar. A missed plugin update is the single most common way a WordPress site gets hacked, and it’s also the easiest to prevent.
Troubleshooting the clean-up
The site shows a critical error after replacing core files. A plugin or theme may depend on a modified file, or you copied files from a different WordPress version. Check the PHP error log, and make sure the fresh download matches your version. Our guide to fixing “there has been a critical error on this website” walks through it.
The redirect still happens for visitors but not for you. Many infections only redirect logged-out visitors, visitors from Google, or mobile users. Test in a private window, on mobile data, and by clicking through from a Google result. Check .htaccess, wp-config.php and the database options table for injected redirects.
The hidden admin comes back. Something is recreating it, usually a backdoor in a plugin, theme or must-use plugin, or a scheduled task. Search the database’s options table for unfamiliar scheduled events and recheck mu-plugins.
Google still shows the warning. Request a review in Search Console after cleaning. The warning stays until Google rechecks.
Your host keeps suspending the site. Ask for the exact file paths their scanner flagged. Hosts often have better visibility than a plugin.
When to call a professional
Get help if:
- The site handles payments or personal data, and you may have a legal duty to report a breach.
- Reinfection happens after you’ve followed every step.
- You can’t access the server or database.
- The site earns money every hour it’s down.
A professional clean-up costs money, but less than repeated downtime or a breach notification.
Heads-up: our Virusdie, Solid Security and Jetpack links are affiliate links. If you buy through them, DroidCrunch earns a commission at no extra cost to you.
Frequently asked questions
How did my WordPress site get hacked?
Most often through an outdated plugin or theme with a known vulnerability, a weak or reused password, or a compromised hosting account. Less often through a nulled premium plugin with malware built in. Your host’s access logs around the infection date can show which file was hit first.
Can I just restore a backup instead of cleaning?
Yes, if you have a backup from before the infection and know roughly when it happened. You’ll lose changes made since. Restoring doesn’t fix the vulnerability, so update everything, change all passwords and harden the site straight away, or it will be reinfected.
Will deleting the infected plugin remove the malware?
Rarely on its own. Attackers usually plant backdoors in several places, such as uploads, must-use plugins and the database, so the site can be reinfected after the original hole is closed. Follow the full clean-up, not just the plugin removal.
How long does WordPress malware removal take?
For a small site, a careful manual clean-up takes a few hours, most of it checking files and the database. Our scripted test took seconds because we knew exactly what we’d planted. Professional services typically clean a site within a day.
Is my visitors’ data at risk if my site was hacked?
Possibly. If the site stores customer accounts, orders or form submissions, the attacker may have accessed them. Depending on where you and your visitors are, you may have a legal duty to report a breach. Get advice if personal or payment data was involved.
Do free security plugins remove malware?
Most free plugins detect malware and some can repair core files, but full cleaning is usually a paid feature or service. A free scanner plus the manual steps above is enough for many small sites. Use a paid service if the infection keeps returning.
How do I know the malware is completely gone?
Core checksums match, no PHP files sit in uploads, every administrator is someone you recognise, the database has no injected scripts, and logged-out visitors on mobile see no redirects. Then watch for two weeks. If nothing returns, the clean-up worked.
Should I tell Google my site was hacked?
Only if Google flagged it. In that case, fix the site, then request a review in Search Console’s Security issues report. If Google didn’t flag it, there’s nothing to report, but check Search Console for spam pages indexed under your domain.
The bottom line
Cleaning a hacked WordPress site follows the same order every time: contain, back up, replace core, remove backdoors and rogue users, clean the database, reset secrets, then harden. In our test, checksums found the modified core file instantly, while the hidden admin only showed up in the database.
Don’t stop at removing files. Close the way in, turn on two-factor authentication, keep backups, and watch the site for two weeks afterwards.



