Hacked WordPress Site: What to Do First
Redirects, strange pages or a Google warning? Contain the damage, change every password, restore clean files and close the way in.
Common signs: visitors are sent to other sites, strange pages appear in Google, unknown admin users exist, your host suspended the site, or a browser warns visitors.
1. Stay calm and make a copy
If you can, download a copy of the site and database before changing anything. It helps to find out how the attacker got in.
2. Contact your host
Many hosts scan for malware and can tell you which files are infected. Some will restore a clean backup.
3. Change every password
Change them from a clean computer:
- Hosting account and FTP/SFTP.
- Database password (and update
wp-config.php). - All WordPress users, mostly administrators.
- Email accounts linked to the site.
4. Restore from a clean backup
The most reliable fix is to restore a backup from before the hack. Then update WordPress, all plugins and the theme straight away, because the old versions are probably how the attacker got in.
5. No clean backup? Clean by hand
- Reinstall WordPress core: replace
wp-adminandwp-includeswith fresh copies, and replace the root files. - Reinstall plugins and the theme from their official source. Delete any you do not use.
- Look in
wp-content/uploadsfor.phpfiles. There should be none. - Check Users for administrators you did not create and delete them.
- Replace the secret keys in
wp-config.phpwith new ones from the WordPress secret-key generator. - Check
.htaccessfor redirect rules you did not add.
6. Close the way in
- Keep everything updated, and delete unused plugins and themes.
- Use strong, unique passwords and two-factor login.
- Install a trusted security plugin, and keep regular backups off the server.
7. Clear the warnings
If Google flagged the site, request a review in Google Search Console after cleaning.
When to get help
If you cannot find the infection, or it keeps coming back, hire a specialist. Contact us if you want help.
Related guides
- WordPress User Can't See Posts They Created: Roles and Permissions
- WordPress Site Health Warnings: What To Fix First
- WordPress: Create a New Admin User via Database When Locked Out
- WordPress Automatic Updates: Enable, Disable and Safe Settings