By Chirag Chudasama··6 min read
WordPress site hacked? The first hour, and how to stop it happening again
Spam pages, strange redirects or a Google warning? The order to work in during the first hour of a WordPress hack, and the habits that stop a repeat.
- Security
- WordPress
Key takeaways
- Don't start by deleting files: write down what you see, copy the infected site, then lock down every login.
- Almost all WordPress vulnerabilities are in plugins (91% in Patchstack's 2025 data), and the ones attackers favour are exploited within hours of disclosure.
- After cleaning up, request a review in Search Console's Security Issues report, but only once every issue is fixed.
You open your site and it redirects to a casino. Or Google shows 'This site may be hacked' under your listing. Or your host emails to say your account is suspended for sending spam. Whatever the sign, the next hour matters more than the next week, and the most common mistake is to start deleting things straight away.
This is the order I'd work in. It follows the steps in WordPress.org's own guide for hacked sites and Google's Search Console documentation, arranged for a small business site on shared hosting.
Why WordPress sites get hacked
Rarely through WordPress itself. Patchstack's report on 2025 counted 11,334 new vulnerabilities in the WordPress ecosystem, 42% more than in 2024. 91% were in plugins and 9% in themes. WordPress core had six, all low priority.
Speed is the bigger problem. Patchstack found that the vulnerabilities attackers use heavily were mass-exploited a median of about five hours after disclosure, and 46% had no fix from the developer when they were made public. A site that updates plugins once a month is exposed for weeks by design.
Patchstack also tested hosting-level defences against known WordPress attacks, and the common protections blocked only 12% of them. Your host's firewall helps, but it isn't a plan.
The first hour
- Write down what you see: the symptom, when you noticed it, and anything that changed recently, such as a new plugin, a theme update or a new user. WordPress.org calls this the baseline for your incident report. Your host, a developer or Google may all ask for it.
- Copy the site as it is. Download the files and export the database before you change anything, even though they're infected. If the clean-up goes wrong, this copy lets you go back and see exactly what the attacker changed.
- Tell your host. On shared hosting the problem may reach beyond your site, and the host can see logs you can't. Ask whether they've detected malware and whether anything else on the account is affected.
- Change every password: WordPress admins, the hosting panel, SFTP or FTP, the database user, and the email account that can reset all of them. Then replace the security keys in wp-config.php with a fresh set from WordPress.org's key generator. That logs everyone out, including an attacker holding a stolen session.
- Scan your own computer. WordPress.org points out that many compromises start with malware on the owner's laptop stealing saved logins. Changing passwords on an infected machine hands over the new ones too.
- Take the site offline if customers could be harmed. If it's sending visitors to scams or could be skimming card details, a few hours behind a maintenance page costs less than the damage to customers and your reputation.
Cleaning up
If you have a backup from before the hack and know roughly when it happened, restoring it is usually the fastest way back. But a restore also brings back the vulnerable plugin the attacker used, so update everything immediately and assume the hole is still open until you've found it.
Without a clean backup, the work looks like this:
- Replace wp-admin and wp-includes with fresh copies of the same WordPress version, uploaded over SFTP. Don't rely on the dashboard's reinstall button: it overwrites known files but leaves behind new ones the attacker added.
- Reinstall every plugin and theme from its original source, at the same versions, and delete the ones you don't use.
- Look hard at .htaccess, index.php and the theme's header.php, footer.php and functions.php. They run on every page load, which makes them favourite places for injected code.
- Search wp-content/uploads for .php files. That folder should hold images and documents. A PHP file there is almost always a backdoor.
- Check the Users screen for admin accounts you don't recognise.
- Run a scanner from inside the site (a security plugin) and one from outside (a remote scanner), since each catches different things.
Patchstack's report notes that attackers increasingly leave persistent footholds, such as uploader scripts, so they can come back after a clean-up. If the site is reinfected within days, something was missed. That's the point to bring in a professional rather than repeating the same steps.
Once the site is clean, change all the passwords again. The first change locked the attacker out while you worked. The second makes sure nothing captured during the clean-up still works.
Getting Google to trust the site again
If Google flagged the site, open the Security Issues report in Search Console. It lists the issue type (hacked content, malware or social engineering) with sample URLs. Google says to fix the problem across the whole site, not just the samples, because a partial fix won't get you a partial return to search results.
Then select Request Review and explain the problem, what you did and the result. Reviews take from several days to several weeks. Don't resubmit while one is pending, and don't ask before the site is fully clean. Google warns that premature requests can slow down future reviews.
Stopping it happening again
- Remove plugins you don't use, and replace ones that haven't been updated in a year. Every plugin is someone else's code running with full access to your site.
- Turn on automatic updates for plugins from developers you trust, so fixes arrive in hours, not weeks.
- Use two-factor authentication on every admin account, and give everyone else the lowest role that does their job.
- Keep daily backups stored off the server, and test a restore every few months. A backup you've never restored is a hope, not a backup.
- Keep PHP on a supported version. PHP2Shell showed that even a well-maintained WordPress site depends on the server underneath being patched.
- Set up uptime monitoring and Search Console email alerts. Both are free, and they often tell you about a problem before your customers do.
Frequently asked questions
What should I do first if my WordPress site is hacked?
Write down what you see and when, copy the files and database as they are, and tell your host. Then change every password and replace the security keys in wp-config.php. Start cleaning only after that.
How do WordPress sites usually get hacked?
Mostly through plugins. Patchstack's report on 2025 found 91% of new WordPress vulnerabilities in plugins, 9% in themes and only six in WordPress core.
How do I remove Google's 'This site may be hacked' warning?
Clean the whole site, then open the Security Issues report in Search Console, select Request Review and explain what you fixed. Reviews take from several days to several weeks.
Should I just restore a backup?
A backup from before the hack is often the fastest way back, but it also restores the vulnerable plugin. Update everything straight after restoring, and treat the hole as open until you've found it.
If you're dealing with a hacked site right now and want a second pair of hands, contact me. Clean-up and prevention are part of my WordPress maintenance and security service. If the site simply won't load, start with how to find out why a website is down.
Sources
Written by
Chirag Chudasama · Full stack web developer
I'm a full stack web developer who has spent the last few years helping founders, agencies and local businesses turn ideas into products people enjoy using. Find me on GitHub and LinkedIn.