A hacked WordPress site requires an orderly response. The reflex to delete files or immediately restore a backup can erase useful clues. Worse, the site can be compromised again if the root cause remains active.
Start by limiting the damage, preserve what will help you understand the incident, then rebuild a reliable environment. The official guide FAQ My site was hacked on WordPress.org specifically recommends documenting symptoms, making a copy of the environment, and changing access credentials once cleanup is complete.
1. Isolate the site before attempting a fix
If your site is redirecting visitors, showing suspicious content, sending unauthorized emails, or creating unknown accounts, reduce its exposure. Contact your host first. Ask them to temporarily suspend the public site, block the affected access, or advise the least risky measure for your situation.
Avoid continuing to publish, installing plugins, or changing multiple settings at the same time. Every change muddles the timeline. Also, an attacker can use the site to infect visitors, send spam, or host fraudulent content.
If you run a store, temporarily disable affected orders and payment methods. Also notify your payment provider if you suspect their settings or access keys were altered. This protects your customers during the investigation.
Record what you observe
Create a short incident log from the start. Note the date, time, and time zone. Add screenshots of redirects, alert messages, unknown admin accounts, and emails received. Also keep the relevant URLs and recent changes made.
These notes help your host or a specialist determine the scope of the issue. They also prevent you from confusing an initial symptom with a consequence that appeared later.
2. Preserve a copy before cleaning
Before deleting anything, download a complete copy of the files and export the database. This copy may be infected. However, it is still useful for comparing files, recovering recent content, or checking what was modified.
Do not confuse this analysis copy with a restoration backup. A backup useful for restoring the site must predate the compromise and be sufficiently verified. If you have multiple restore points, choose the one that predates the earliest known sign of the problem.
To prepare this choice without acting blindly, consult how to test restoring a WordPress backup. A test restore in a separate environment allows you to verify the copy without bringing the compromised site back online.
3. Change all credentials that might be affected
Change passwords from a trusted device. Do not limit yourself to the WordPress admin account. A compromise can come from access to hosting, email, or a technical account that stores credentials.
- Change access to the hosting panel, SFTP or SSH, and the database.
- Reset the passwords for all WordPress administrators.
- Verify the email address associated with administrator accounts.
- Revoke and recreate API keys, external service tokens, and payment access if you use them.
- Review WordPress accounts and delete any you do not recognize.
Administrators can create, delete, and modify users, plugins, and themes. So check carefully who has this role. If necessary, review roles and permissions in WordPress before restoring access to your team.
4. Clean by rebuilding trusted components
A simple scan or deleting a suspicious file doesn’t prove the site is clean. Added files, unauthorized accounts, or external access may remain. Instead, work from trusted sources and a clear list of items to keep.
Replace core WordPress files
WordPress recommends replacing the directories wp-admin and wp-includes with clean copies, then examine more closely wp-content, which contains themes and plugins. See the precautions described in the official documentation on a hacked WordPress site before proceeding.
Reinstall each plugin and theme from its legitimate source. Remove unused plugins, themes, and files you cannot identify. Keep a copy of any customized item before replacing it, then inspect that code separately.
Also check configuration files, notably wp-config.php and server rules such as .htaccess. Do not blindly restore these files from a compromised copy. Instead compare them to a trusted version and keep only the necessary settings.
Handle the database with care
A database can contain added content, unknown accounts, or altered settings. If you restore a healthy database, then check users, critical settings, and recent content. If no healthy copy exists, get help before deleting data at random.
You may need to preserve recent orders, form submissions, or posts. In that case, retrieve only validated data. Do not blindly reimport an entire backup made after the incident began.
5. Restore the site into a fixed environment
Restoring comes after cleaning up access and fixing the probable cause. Update WordPress, retained themes, and plugins. WordPress emphasizes that plugin and theme updates help site security, but first take a fresh clean backup and check compatibility.
You can follow a controlled method in this guide to update WordPress without breaking your site. Test changes in a working copy when your host allows it.
Before reopening the site, at minimum check important pages, admin login, forms, transactional emails, user accounts, and the checkout flow. Also review logs provided by the host to confirm no suspicious activity continues.
6. Harden the site after recovery
Once the site is stable, look for the likely entry point. This could be stolen credentials, a vulnerable plugin, an unmaintained theme, an infected workstation, or exposed hosting access. Do not present a hypothesis as a certainty without verifiable evidence.
The WordPress hardening guide in particular recommends using SFTP when offered by the host, limiting write permissions, and protecting sensitive files. These measures reduce the opportunities for unauthorized modification.
Finally, implement backups separate from the server and verify that they can actually be restored. To structure this step, consult how to create a reliable automatic WordPress backup. After an incident, a tested backup becomes an essential part of your recovery plan.
If you cannot determine the extent of the compromise or confidently clean the files, keep the site isolated and entrust the analysis to your host or a specialist. Restoring a site quickly is useful, but restoring a reliable site is more important.









