Finding out your website has been hacked is stressful, and rushed fixes often make things worse. The good news is that most infections follow a pattern, and a calm, ordered clean-up works. This guide from WPOptimizers walks through ten steps, from the first minute to the final review request.
What Should You Do First When Your WordPress Site Is Hacked?
Stay calm and contain the problem before touching anything. WPOptimizers recommends three immediate actions: tell your host, change passwords from a clean device, and take a backup of the infected site as evidence. Do not delete files at random, because that can destroy clues and break the site further.
The official WordPress guide to a hacked site also advises checking with your hosting provider, since a hack on shared hosting can affect more than one site.
Work through the steps below in order. Each one reduces the chance of the infection returning, and skipping steps is the main reason hacks come back within days.
Step 1: How Do You Confirm the Site Is Really Hacked?
Look for clear signs before assuming the worst. WPOptimizers checks for redirects to strange sites, unknown admin users, spam pages in Google results, browser or Google warnings, unexpected slowdowns, and files you did not create. One sign alone can have a harmless cause, but two or three together almost always mean a compromise.
| Sign | Where to Check | What It Often Means |
| Redirects to unknown sites | Visit the site on mobile and in a private window | Injected redirect code |
| Unknown admin users | Dashboard, then Users | Backdoor account |
| Spam pages in search results | Search “site:yourdomain.com” in Google | SEO spam injection |
| Browser or Google warning | Search Console, then Security Issues | Flagged malware |
| Sudden slowdown or host warning | Host dashboard and emails | Malicious scripts or mining |
| Locked out of login | Try password reset | Credentials changed |
Wordfence lists similar warning signs, including a site that crashes unexpectedly or a scanner flagging modified files. Mobile-only redirects are common, so test on a phone as well.
Step 2: How Do You Contain the Damage Quickly?
Limit what the attacker can do while you clean. WPOptimizers suggests putting the site into maintenance mode or temporarily blocking public access, changing your hosting, FTP, and database passwords, and removing unknown users. Containment stops further spread and protects visitors from malware while you work.
If your host offers a staging copy or a snapshot, use it. Many hosts will also scan the account and tell you which files they flagged.
Use a clean computer for password changes. If your own device has a keylogger, new passwords will be stolen as soon as you type them.
Step 3: Why Should You Back Up the Infected Site?
An infected backup is your evidence and your safety net. WPOptimizers saves a full copy of the files and the database before any clean-up, labelled clearly as infected. If a clean-up step breaks the site, you can return to that copy, and a specialist can examine it to learn how the attacker got in.
Store this copy offline, not on the same server. Do not restore it to the live site; it is only a record.
This feels strange, but it is standard practice among professionals. A second, older clean backup is even more valuable, and the next step is to find one.
Step 4: How Do You Find a Clean Backup?
Look for the most recent backup from before the first sign of trouble. WPOptimizers checks backup dates against the date of the earliest suspicious file or event. Restoring too recent a copy brings the infection straight back, while restoring too old a copy can lose orders or content.
Check your host’s backups and any plugin or cloud backups. This guide to backup plugins explains how different tools store restore points.
If you restore, treat it as a rebuild step, not the end. The vulnerability that let the attacker in is still there until you patch it, so continue with the remaining steps.
Step 5: How Do You Scan and Locate the Malware?
Scan the whole installation, not just WordPress. WPOptimizers uses a security scanner to compare core files against official copies, then checks plugins, themes, uploads, and the database. Malware often hides in the uploads folder, in fake plugins, or inside database entries that a file scan alone will miss.
Security plugins such as Wordfence, Sucuri, and MalCare detect known signatures. Read this comparison of malware scanner plugins to understand what each can and cannot find.
Write down every suspicious file and its path. SiteLock also notes that malware can sit in files, plugins, themes, uploads, and database entries, so a thorough clean-up goes beyond removing the first suspicious file you find.
Step 6: How Do You Remove Infected Files and Replace Core Files?
Replace, do not repair. WPOptimizers reinstalls fresh copies of WordPress core, plugins, and themes from official sources, which overwrites any modified code. It then deletes unknown files, unused themes, and plugins you do not need. Never copy replacement files from another website, as they may be infected too.
Keep your configuration file and uploads, but inspect them line by line. Look for strange code in wp-config.php, .htaccess, and the active theme’s functions file.
Be careful with “nulled” or pirated plugins. They are a common source of backdoors, and the safest fix is to delete them and buy or replace them properly.
Step 7: How Do You Clean the Database and Remove Rogue Users?
Check the database for injected content. WPOptimizers reviews posts and pages for hidden links or scripts, checks the options table for unfamiliar entries, and removes unknown administrators. A site can look clean in the file system while the database still redirects visitors or loads spam.
Search for unusual script tags, base64 strings, and links to unrelated sites. If you are not confident editing the database, ask a specialist, since a wrong change can break the site.
Review all user accounts. Remove anyone you do not recognise and reset passwords for those who remain, especially administrators and editors.
Step 8: How Do You Reset Passwords, Keys, and Access?
Reset everything the attacker may have seen. WPOptimizers changes WordPress user passwords, hosting and database passwords, FTP and SSH credentials, and regenerates the WordPress secret keys. New keys log out every active session, including any the attacker still holds, so this step closes a door many guides skip.
WordPress.org provides a secret key generator for exactly this purpose. Paste the new values into your configuration file.
Turn on two-factor authentication for all administrators. A leaked password then becomes far less useful to an attacker.
Step 9: How Do You Update Everything and Close the Entry Point?
Patch the hole that let them in. WPOptimizers updates WordPress, plugins, and themes after the clean-up, deletes anything unused, and looks for the likely entry point such as an outdated plugin. Without this, the attacker or a bot will often return through the same weakness within days.
Patchstack’s report found that 91% of new WordPress vulnerabilities were in plugins, so plugins deserve the closest look. Check your logs for the first suspicious request if your host provides them.
Add a firewall and login protection now. These are cheap compared with a second clean-up.
Hacked and Short on Time?
WPOptimizers can scan your site, remove malware, patch the weakness, and put protection in place so the same problem does not come back.
Step 10: How Do You Remove Google and Browser Warnings?
Request a review once the site is clean. WPOptimizers checks Google Search Console under Security Issues, confirms the flagged problems are gone, then submits a review request describing what was fixed. Reviews often take several days, and the warning stays until Google confirms the site is safe.
Also remove spam URLs by fixing the cause, updating your sitemap, and checking that no spam pages are still indexed. Redirects and hidden pages can keep returning if a backdoor survives.
Monitor the site closely for a few weeks. Check logs, users, and file changes, because a surviving backdoor often shows itself again soon after.
How Can You Stop Your Site From Being Hacked Again?
Prevention is a routine, not a plugin. WPOptimizers recommends regular updates, off-site backups, a firewall, two-factor login, limited user roles, and monitoring. Each layer is modest on its own, but together they make a hack far less likely and far cheaper to recover from.
Here is a short checklist to follow after the clean-up:
- Turn on automatic backups stored off the server.
- Update plugins and themes weekly.
- Delete anything unused.
- Use strong, unique passwords and two-factor login.
- Install a firewall and malware scanner.
- Review user accounts every quarter.
- Test a restore at least twice a year.
Patchstack data summarised by one developer write-up put the median time to first mass exploitation at around five hours, which is why prompt patching matters.
Should You Clean It Yourself or Hire a Professional?
Clean it yourself only if you are comfortable with files, databases, and backups, and the infection is simple. WPOptimizers advises hiring help when malware keeps returning, the site holds customer data, or revenue depends on it. A half-finished clean-up can leave backdoors that cost more later.
Warning signs that you need an expert include repeated reinfection, unknown admin users reappearing, and a host that has suspended your account.
WPOptimizers lists malware cleanup in its maintenance FAQ and offers security monitoring in its monthly plans, so ongoing protection can sit alongside any emergency fix.
Frequently Asked Questions About WordPress Malware Removal
How do I know if my WordPress site is hacked?
Look for redirects, unknown admin users, spam pages in Google, security warnings, slowdowns, and files you did not create. Two or more signs together strongly suggest a compromise.
Can I remove WordPress malware with a plugin alone?
Sometimes, for simple infections. Plugins detect known patterns, but backdoors in the database or hidden files can survive, so verify the clean-up manually or with an expert.
How long does malware removal take?
A simple infection can take a few hours. Complex or repeated infections take longer, plus extra days for Google to review a warning.
Will I lose my SEO rankings after a hack?
Rankings can drop if spam pages are indexed or Google flags the site. Fast clean-up and a review request usually limit the damage.
Should I restore from a backup after a hack?
Yes, if you have a clean one, but patch the entry point afterwards. Restoring alone leaves the original weakness open.
Why does my site keep getting hacked again?
A backdoor, an outdated plugin, stolen credentials, or an infected hosting account usually survived the clean-up. Check all four.
How much does malware removal cost?
Prices vary widely with the size and complexity of the infection. Ask for scope in writing, including whether re-cleaning is covered if malware returns.
What Should You Remember About WordPress Malware Removal?
- Contain the problem, tell your host, and save an infected copy first.
- Replace core, plugin, and theme files rather than editing them.
- Check the database and user accounts as well as files.
- Regenerate secret keys and reset every credential.
- Patch the entry point or the hack will return.
- Request a Google review once the site is clean.
- WPOptimizers lists security monitoring and malware cleanup in its maintenance offering.
What Is the Best Next Step After a Clean-Up?
The best next step is to set up protection so you never repeat this. WPOptimizers can review your updates, backups, and firewall, then place the site on a monitored plan. A small monthly cost is usually far cheaper than another emergency clean-up and the downtime that comes with it.
Keep Your Site Protected Going Forward
WPOptimizers monitors security, keeps updates and cloud backups on schedule, and responds when something looks wrong, so one bad day does not become a pattern.