If your WordPress site has been hacked, act in this order: contain the problem, back up the infected site, change every password, find and remove the malicious code, update everything and then harden the site. Restoring an old backup alone is not enough if you do not close the hole the attacker used.
Signs your WordPress site may be hacked
- Visitors are redirected to spam or unfamiliar sites
- Pages, posts or administrator users you did not create
- Your host suspends the site or sends a malware warning
- Google or your browser shows a security warning
- Spam emails are sent from your domain
- You are locked out of your admin account
1. Contain the damage
Contact your hosting provider straight away, because many hosts can scan the account and isolate it. Put the site in maintenance mode or restrict access while you work, and note when you first saw the problem and what you changed recently.
2. Back up the infected site first
It sounds odd, but a copy of the current state gives you something to roll back to if the cleanup goes wrong and helps you investigate later. Label it clearly as infected and keep it off the live server. Never restore it to production.
3. Change every password and key
- WordPress administrator and editor accounts
- Hosting control panel, SFTP and SSH
- The database password (update wp-config.php to match)
- Email accounts connected to the site
- The security keys and salts in wp-config.php, which also logs everyone out
Use long, unique passwords from a password manager, and never share them in chat or email.
4. Check users and roles
Open Users and remove any administrator you do not recognize. Make sure each account only has the role it needs, and delete old accounts that are no longer used.
5. Update and remove what you do not need
Update WordPress core, every plugin and every theme. Delete plugins and themes you are not using. Remove any nulled or pirated plugin or theme immediately, because they often contain malware.
6. Replace core files and inspect the rest
- Download a fresh copy of WordPress from WordPress.org.
- Replace the wp-admin and wp-includes folders and the core files in the site root with clean copies, keeping your wp-config.php.
- Reinstall plugins and themes from their official sources instead of reusing the existing files.
- Inspect wp-content, especially the uploads folder, for PHP files, the mu-plugins folder for unknown files and the .htaccess file for strange rules.
If you are not sure which files are safe to delete, stop and get help. Removing the wrong file can break the site.
7. Scan and confirm the site is clean
Run a malware scan, using your host scanner or a reputable security plugin, and check the site again for redirects and unknown content. If Google flagged the site, fix it first and then request a review in Google Search Console.
8. Find the entry point and close it
- Check for outdated or vulnerable plugins and themes
- Enable two-factor authentication for administrators
- Limit login attempts and use strong passwords
- Keep automatic off-site backups and test restoring them
- Review user accounts regularly
Our guides on WordPress security best practices and how to back up and restore your WordPress site cover prevention in more detail.
Quick checklist
- Host contacted and access to the site restricted
- Infected copy backed up and clearly labeled
- All passwords, the database password and the security keys changed
- Unknown users removed
- Everything updated, and unused or nulled items deleted
- Core files replaced from WordPress.org and plugins reinstalled
- Malware scan is clean and the site was retested
- The entry point was found and closed
What to do after the cleanup
- Watch logins and file changes closely for several weeks
- Check Google Search Console for security issues
- Consider telling affected users if their data may have been exposed
- Schedule regular scans and test your backups
When to get professional help
Get help if you cannot find the infection, if it keeps coming back, if customer data may have been exposed or if the site is business-critical. Our WordPress fixes and troubleshooting service handles cleanup, and our maintenance and support plans keep updates and backups under control afterwards. Contact us and we reply within 24 hours.
Frequently Asked Questions
Can I just restore a backup?
Only if the backup is from before the infection and you also find and fix how the attacker got in. Otherwise the site can be hacked again.
How do I get Google to remove the security warning?
After the site is clean, open Google Search Console, review any security issue it reports and request a review.
How can I tell which files were changed?
Compare WordPress core files with a clean download from WordPress.org, and compare plugins with the versions in the official repository. Files that do not match deserve a closer look.
Further reading: WordPress.org documentation: FAQ My site was hacked.