Home/Blog/WordPress
WordPress · Security · Recovery

WordPress Site Hacked? What to Do Now

Naveen Goyal
26 November 2026
3 min read
WordPress
Short answer

Don't just delete the one bad file you can see. Back up the hacked site as evidence, change every password and the secret keys, replace WordPress, plugins and themes with clean copies, remove unknown admin users and stray PHP files, then find how they got in and close it.

Signs your site is hacked

  • Visitors are redirected to spam or scam sites, often only on mobile or from Google.
  • Admin users you did not create.
  • Google shows "This site may be hacked", or spam pages appear in search results.
  • Your host suspends the site or emails you about malware.
  • PHP files inside wp-content/uploads, which should only hold media.

1. Contain it

Download a full backup of the files and database as they are now. It is evidence, and you may need it to see what changed. Tell your host; many can scan and help. If visitors are being redirected, put the site in maintenance mode while you work.

2. Change every password and the secret keys

Change the hosting panel, SFTP/FTP, database user and every WordPress administrator password. Then replace the secret keys in wp-config.php with fresh ones from https://api.wordpress.org/secret-key/1.1/salt/. That logs out everyone, including the attacker.

3. Remove unknown users

Go to Users and delete any administrator you do not recognise. Check the database too, because some attacks hide users from the list.

4. Replace files with clean copies

Don't try to edit infected files one by one. Replace them. With WP-CLI you can find modified files first:

wp core verify-checksums
wp plugin verify-checksums --all

Reinstall WordPress core from Dashboard → Updates, and reinstall every plugin and theme from its official source. Delete any plugin or theme you don't use, and never use "nulled" copies of paid plugins. Then look for PHP files in uploads:

find wp-content/uploads -name "*.php"

5. Check the database

Attackers often inject scripts into posts, widgets or options. Search for them with WP-CLI and clean what you find:

wp db search '<script' --all-tables

6. Close the hole

  • Update everything that was out of date; an old plugin is the most common way in.
  • Limit login attempts and add two-factor authentication. See how to limit login attempts.
  • Turn off file editing in wp-admin: define( 'DISALLOW_FILE_EDIT', true );
  • Give each person the lowest role they need.

If Google flagged the site, open Search Console → Security issues and request a review once it is clean.

Stay safe from now on

Keep automatic backups stored off the server, update weekly, and watch logins. NaveenCodes Login Guard blocks brute-force attacks, logs every login attempt and adds 2FA, all on your own server.

Frequently asked questions

What should I do first if my WordPress site is hacked?

Back up the site as it is, change every password and the secret keys in wp-config.php, and tell your host.

How do I find malware in WordPress?

Compare core and plugin files with their official checksums using WP-CLI, look for PHP files in wp-content/uploads, and search the database for injected scripts.

Will deleting the bad file fix my hacked site?

Rarely. Attackers usually leave several backdoors. Replace core, plugins and themes with clean copies instead.

How do I remove the "This site may be hacked" warning?

Clean the site, then request a review in Google Search Console under Security issues.

Free tool: Login Guard

Brute-force lockouts, a login log, IP block and allow lists, email alerts and two-factor authentication.