If your WordPress site was hacked, first lock the attacker out: change every password and remove any admin account you do not recognize. Then find what they changed, clean or replace it, close the way they came in, and ask Google to review the site if it shows a warning. Change the passwords before you clean anything: if you clean first, the attacker can log back in the next day and undo it.
Signs your site was hacked
- Visitors are sent to spam, pharmacy or betting sites, sometimes only on mobile or only when they arrive from Google.
- The browser shows a red warning before your site loads, or Google shows "This site may be hacked" under your result.
- Search results for your site show pages you never wrote, often in another language.
- There are admin users, plugins or files you did not add.
- Your host suspended the account or emailed you about malware or spam being sent.
Some hacks are hidden from logged-in users, so check from a private window and from your phone, not only from your usual browser.
1. The first hour: lock them out
- Take a copy of the site as it is now, files and database, and keep it apart from your clean backups, so you can compare it later and see exactly what was changed.
- Change every password: the hosting account, SFTP, the database, and every WordPress administrator. Use your host's panel for the first three, since the attacker may be watching wp-admin.
- Review the users. In Users, filter by Administrator and delete any account nobody on your team created. Check the email addresses too: attackers like names that look like a developer or the hosting company.
- Log everyone out by changing the security keys (salts) in
wp-config.php. You can generate new ones at api.wordpress.org/secret-key/1.1/salt/.

2. Find what they changed
Look in the places attackers like to hide things:
- The plugin list. In two cleanups we did this fall, the way in was the same: a plugin with a believable name that nobody had installed, and an admin account nobody had created.
wp-content/mu-plugins/, which runs code without showing up in the normal plugin list.wp-config.php,.htaccessand the theme'sfunctions.php, for code that loads something from another site or redirects visitors.wp-content/uploads/, which should only hold media: a.phpfile in there is a red flag.- Files changed recently. Your host's file manager or a security plugin such as Wordfence or Sucuri can list them and compare core files with the originals.

3. Clean, or replace with clean copies
Do not try to clean WordPress core files one by one. Reinstall them, and reinstall each plugin and theme from its official source, so every file is the original. Your own content lives in the database and in uploads, so those are what you clean by hand: remove suspicious files in uploads and look for injected scripts or spam links in posts, pages and widgets.
You can also restore a backup, but only if you know it is from before the hack. Many sites were infected weeks before anyone noticed, and restoring a backup from that time brings the problem back. Either way, the passwords from step 1 must change again after the restore.
4. Close the door
- Update WordPress, every plugin and the theme.
- Delete plugins and themes you do not use, and anything downloaded from an unofficial or "nulled" site.
- Turn on two-factor authentication for every administrator.
- Give each person only the role they need: an editor does not need to be an administrator.
- Disable the file editor in the dashboard by adding
define( 'DISALLOW_FILE_EDIT', true );towp-config.php.

5. Ask Google to remove the warning
If Google flagged the site, open Search Console, go to Security issues, confirm the problems are fixed and request a review. Reviews usually take from a day to a few days. Ask only when the site is really clean: a review that fails makes the next one take longer.
6. Watch it for a few weeks
For the next weeks, check the user list and the plugin list now and then, keep an eye on the file changes your security plugin reports, and search Google for site:yourdomain.com to spot spam pages. A hack that comes back within days usually means the way in is still open, or a hidden file was missed.