HowTo

How to Fix a Hacked WordPress Site Step by Step

Fix a Hacked WordPress Site – How to Fix a Hacked WordPress Site Step by Step

In this guide: How to fix a hacked WordPress site step by step: the first 30 minutes, backing up the hacked state, cleaning or restoring, closing the vulnerability, and…

Discovering your website has been hacked is stressful. Your site may be redirecting visitors, showing spam, or flagged by Google. The key is to act methodically: contain the damage, clean or restore, close the hole, and recover your reputation.

Here’s the step-by-step process.

First 30 minutes

1. Confirm the hack.
Look for redirects, defaced pages, spam content, browser warnings, unknown admin users, or a security alert from your host or Google.

2. Contact your host.
Tell them what you’re seeing. Many hosts have security teams, malware scanners, and backups that can help — and they may need to know if your account is sending spam or attacking others.

3. Put the site in maintenance mode (if possible).
This protects visitors from malware or scam redirects while you work.

4. Change critical passwords — from a clean device.

  • Hosting account and control panel
  • SFTP/FTP and SSH
  • Database user (update wp-config.php afterward)
  • All WordPress administrator accounts
  • Email accounts connected to the site

Enable 2FA wherever possible. If your own computer might be infected, scan it first or use another device.

5. Log out all users — changing the security keys in wp-config.php (the “salts”) forces everyone to log in again.

Backing up the hacked state

Before changing files, take a full backup of the infected site (files and database) and label it clearly. You may need it to:

  • Investigate how the attack happened.
  • Recover content that was changed after your last clean backup.
  • Provide information to a security professional.

Store it separately from your clean backups so you never restore it by accident.

Cleaning or restoring

Option A — Restore a clean backup (fastest)

  1. Identify when the infection began (check file modification dates, security logs, and when symptoms started).
  2. Restore a backup from before that date.
  3. Recreate any legitimate content added since then.
  4. Update everything immediately after restoring — the original vulnerability still exists in the backup.

Option B — Clean manually

  1. Replace WordPress core: download a fresh copy of the same version and replace wp-admin and wp-includes (and root core files except wp-config.php). You can also run wp core verify-checksums to find modified core files.
  2. Reinstall plugins and themes from official sources — delete the old folders and install fresh copies. Remove any you don’t use.
  3. Inspect /wp-content/uploads/ for PHP files or other files that shouldn’t be there.
  4. Check wp-config.php and .htaccess for injected code or redirect rules.
  5. Clean the database: search posts, options, and widgets for injected scripts, iframes, and unknown links. Remove unknown admin users.
  6. Check scheduled tasks (cron) for malicious jobs.
  7. Scan again with a server-side scanner and remote scanner.

Option C — Professional cleanup
If the infection is complex, persistent, or you’re not comfortable editing files, hire a professional malware removal service or use your host’s cleanup service.

Closing the vulnerability

If you don’t fix how attackers got in, you’ll likely be hacked again.

  • Update WordPress core, all plugins, themes, and PHP.
  • Remove nulled, abandoned, or vulnerable plugins and themes.
  • Review users: delete unknown accounts, reduce unnecessary admin roles.
  • Enforce strong passwords and 2FA.
  • Install a security plugin or WAF — see Best WordPress Security Plugins.
  • Disable file editing in the dashboard (DISALLOW_FILE_EDIT).
  • Check file permissions.
  • Review access logs (if available) to identify the entry point — suspicious POST requests to specific plugin files often reveal the vulnerability.
  • Follow the full WordPress Security Checklist.

Requesting a Google review

If Google flagged your site:

  1. Open Google Search Console → Security issues.
  2. Confirm the issues are fixed and your site is clean.
  3. Click Request review and explain what you found and what you did to fix it.
  4. Reviews typically take from a few days to a couple of weeks.

Also:

  • Remove spam URLs from Google’s index — make sure they return 404/410 and use the Removals tool for urgent cases.
  • Resubmit your sitemap.
  • Check other blacklists and request delisting if needed.
  • Warn customers if their data may have been exposed, and follow applicable legal notification requirements.

After recovery

  • Monitor your site daily for the next two weeks.
  • Keep automatic daily off-site backups.
  • Scan weekly.
  • Document what happened and how you fixed it.

Further reading: official WordPress documentation

Key Takeaways: Fix a Hacked WordPress Site

  • Contain first: contact your host, change passwords, and protect visitors.
  • Back up the hacked state separately before cleaning.
  • Restore a clean backup or replace core, plugins, and themes with fresh copies.
  • Find and fix the vulnerability to prevent reinfection.
  • Request a Google review once clean.
Z
zasma171

Writes for Hostreta about the topics covered in this article.

Comments (0)

Your email address will not be published. Required fields are marked *

Recent Comments

No comments to show.
Ad · AdSense
Ad space 300×250
Affiliate links
Tools we recommend
Protect Your Website with Automated Daily Backups
$2.09
Get it
the easiest way to manage all of your social media accounts
$29
Get it
Starter Website Get online, properly
$249
Get it
google workspace Business Starter
$3.75
Get it
Nord Vpn Cybersecurity. Built for Everyday Use
$8.99
Get it

We may earn a commission on purchases made through these links, at no extra cost to you.

Ad · AdSense
Ad space 300×600
Ad · AdSense
Ad space 300×600

$ top hosting picks

affiliate
★★★★★

NovaHost

$2.95/mo,renews at $9.95
  • Free SSL + domain, first year
  • 1-click WordPress install
  • 24/7 chat, sub-5-min response
get this deal →
affiliate link · we may earn a commission
★★★★★

CloudRoot

$4.50/mo,renews at $12.95
  • Built-in CDN + caching
  • Daily backups, 30-day retention
  • Staging environments included
get this deal →
affiliate link · we may earn a commission
★★★★★

AI SiteBuilder

$1.49/mo,renews at $13.99
  • 5 Websites
  • Emails & Security Included
  • AI Website Builder for WordPress
get this deal →
affiliate link · we may earn a commission

Never miss a new article

Join thousands of developers and builders getting a weekly digest of the best tech articles.