Skip to content
webfixed

Guides / WordPress

WordPress site hacked: first steps and cleaning it up

By Michael Broadbridge. Last checked 14 November 2026 on WordPress 7.1.

Short answer

Take a full backup of the hacked site as it is now, then change every password: hosting, SFTP, database and each WordPress administrator. Delete admin accounts you do not recognise. Replace WordPress, plugins and themes with clean copies, check wp-config.php, .htaccess and the uploads folder, update everything, then request a review in Google Search Console.

Symptoms

You may see one of these messages:

This site may be hacked

Deceptive site ahead

Dangerous site

  • Visitors are redirected to spam or scam websites.
  • Google shows "This site may be hacked" under your listing, or Search Console reports a security issue.
  • Chrome shows a red warning such as "Deceptive site ahead" or "Dangerous site" before your page opens.
  • A site: search in Google, such as site:yourdomain.co.uk, lists pages you did not create.
  • There are administrator accounts you do not recognise, or your host has suspended the site for malware.

Causes, most likely first

  1. Out of date plugins and themes

    Security holes are fixed in new versions, so a plugin or theme that has not been updated stays open to attack. WordPress itself is the same: older versions no longer receive security updates.

  2. Nulled plugins and themes

    These are paid plugins and themes passed around for free on unofficial sites. There is no way to tell what has been changed in them. WordPress advises installing only from wordpress.org or well known companies.

  3. Weak or reused passwords

    A short password, or one used on another site that has leaked, can be tried on your WordPress login, your hosting account or SFTP.

  4. A compromised hosting account or computer

    Anyone with your hosting, SFTP or database login can change files without going through WordPress. WordPress notes that many attacks start with malware on the owner’s own computer that records these logins.

  5. Abandoned plugins

    A plugin that is no longer maintained gets no security fixes at all. Its page on wordpress.org shows when it was last updated and whether it has been closed.

How to fix it

Keep a copy of the site as it is now

Before you change anything, keep a copy of the hacked site. WordPress’s own advice is to take this snapshot even though it is infected. It records what was changed, and gives you something to go back to if the clean-up breaks the site.

  1. Write down what you have seen, when you first noticed it, and anything that changed recently, such as a new plugin or a theme edit.
  2. Download a full backup of the files and the database from your hosting control panel, or ask your host for one.
  3. Label it as the hacked copy and keep it off the server. Do not restore from it later.
  4. Check how far back your host’s backups go, and whether any are from before the problem started.

If the site stores customer details, the hack may be a personal data breach. The ICO says to report a breach that is likely to put people’s rights and freedoms at risk as soon as possible, and where feasible within 72 hours.

Lock the attacker out

  1. Change the password for your hosting control panel.
  2. Change the SFTP or FTP passwords, and delete any FTP accounts you did not create.
  3. Change the database password in your hosting control panel, then put the new password in the DB_PASSWORD line of wp-config.php, or the site will stop loading.
  4. Filter the list by Administrator and delete any account you do not recognise. When WordPress asks what to do with that user’s content, attribute it to your own account so you can review it.Menu: Users > All Users
  5. Change the password of every remaining administrator, using long, unique passwords from a password manager.Menu: Users > All Users
  6. Open each administrator’s profile, scroll to Application Passwords and revoke any you did not create.
  7. Run a full virus scan on every computer used to log in to the site or the hosting account.

Change all of these passwords again once the site is clean, in case the attacker still had a way in while you worked.

Keep visitors away while you work

  1. Ask your host whether they can take the site offline, or limit it to your own IP address, while you clean it.
  2. If the host has already suspended the site, ask which files or problems they found. That list is a useful starting point.
  3. A maintenance mode plugin hides pages from visitors, but the attacker’s files stay on the server and can still run, so treat it as a screen and not a fix.

Replace WordPress, plugins and themes with clean copies

Hacks often add new files as well as changing existing ones. WordPress advises replacing files by SFTP rather than with the reinstall options in the dashboard, because those overwrite existing files and leave any extra files in place. Posts, pages and settings are in the database and are not affected.

  1. Note the WordPress version you are running.Menu: Dashboard > Updates
  2. Download the same version from wordpress.org. Older versions are listed on the releases page.
  3. Delete the wp-admin and wp-includes folders on the server and upload the clean ones in their place.
  4. Upload the loose files from the main folder of the download, such as index.php and wp-login.php, over the old ones. Leave wp-config.php and the wp-content folder alone for now.
  5. In wp-content, then plugins, delete each plugin folder and upload a fresh copy from wordpress.org or the developer’s own site. Do the same for your themes in wp-content, then themes.
  6. Leave out any plugin or theme you no longer use, and any you cannot get a clean copy of, including nulled ones.
  7. Scan the site with a security plugin such as Wordfence or Sucuri Security, and with an outside scanner such as Sucuri SiteCheck or VirusTotal.

Check the places attackers hide code

Download a copy of each file before you edit it. A mistake in wp-config.php or .htaccess can take the site offline.

  1. Open wp-config.php and compare it with wp-config-sample.php from the clean download. Apart from your database details, security keys and settings you added yourself, there should be nothing you cannot account for, such as a block of unreadable code or a line that loads another file.
  2. Open .htaccess in the main folder. WordPress names it as one of the files most often changed in a hack. Look for redirect rules that send visitors to other websites, and check for .htaccess files in other folders as well.
  3. Open wp-content, then uploads. This folder is for images and documents, so check any file ending in .php and remove it unless you know which plugin created it.
  4. If your theme was custom built and has no clean copy, check index.php, header.php, footer.php and functions.php for code you did not add. WordPress names these as common targets.
  5. Look through all posts, including drafts, for content you did not write, then do the same under Pages.Menu: Posts > All Posts
  6. Check the cron jobs in your hosting control panel for any you did not set up. A scheduled task you did not create can put deleted files back.
  7. Replace the security keys in wp-config.php. Generate a new set at api.wordpress.org/secret-key/1.1/salt/ and paste them over the eight lines that start with define( 'AUTH_KEY' through to define( 'NONCE_SALT'. This logs everyone out, including the attacker.

Update everything and ask Google for a review

  1. Update WordPress, every plugin and every theme to the latest version.Menu: Dashboard > Updates
  2. Change all the passwords from the lock out step again.
  3. Turn on two-factor login for every administrator, for example with the free Two Factor plugin from wordpress.org.
  4. Sign in to Google Search Console and open the Security issues report. It lists the problem Google found, such as Hacked: URL injection, with sample addresses.
  5. Check every sample address is clean, then click Request Review. Explain what the problem was, what you did to fix it, and the result.
  6. Wait for the outcome before sending another request. Google says a review can take from a few days to a few weeks, and it removes the "This site may be hacked" label once it has checked the site is fixed.

Google does not lift warnings for part of a site, so fix every affected page before you request a review.

If that didn’t work

  1. The hack comes back

    The way in is still open. Google warns that a site is likely to be reinfected unless the security hole is fixed, so look again at old plugins, passwords and other sites on the same hosting.

  2. Another site on the same hosting account

    On shared hosting a hack can reach more than one site. Old test copies and forgotten sites in other folders need cleaning or deleting too.

  3. Google sees different content from you

    Some hacks show spam only to Google. Use the URL Inspection tool in Search Console to see a page as Google sees it.

When to get help

Stop if the hack comes back after you have cleaned it, if you cannot find how the attacker got in, or if the site takes payments or stores customer details. It is also time to stop if you are not comfortable deleting and uploading core files over SFTP, or if editing wp-config.php or .htaccess has taken the site offline.

What a developer would check

  • Server access logs from around the time of the hack, to find how the attacker got in.
  • Every file compared against clean copies of WordPress, the plugins and the theme, including files that should not be there at all.
  • The database for spam posts, injected scripts, unknown users and changed site address settings.
  • Hosting cron jobs, SFTP accounts and other sites on the same hosting account.

Describe the problem in your own words and WebFixed gives you an instant fixed quote. Nothing is charged until you accept it.

Related questions

Can I just restore a backup from before the hack?
Yes, if you have one and know roughly when the hack started. Restoring removes the attacker’s files but not the way they got in, so update everything and change every password straight afterwards. Anything added to the site since the backup date will be lost.
Will replacing WordPress, plugins and themes delete my content?
No. Posts, pages and settings are stored in the database, and images are in the uploads folder. Replacing wp-admin, wp-includes, plugins and themes does not touch either, which is why wp-config.php and uploads are checked by hand instead.
How long does Google take to remove the hacked warning?
Google says a review can take from a few days to a few weeks. Request it only once the whole site is clean, and do not send another request while one is pending.

Written by Michael Broadbridge, Founder of Webgro. First published 14 November 2026. Last checked 14 November 2026 on WordPress 7.1.