How to Recover a Hacked WordPress Website: Step-by-Step Guide

9 Aug 2026Updated 26 Sept 202610 min read
Sefat Hossain, WordPress security specialist
By Sefat Hossain
Share
How to Recover a Hacked WordPress Website: Step-by-Step Guide

Quick answer

Learn how to recover a hacked WordPress website, investigate the compromise, remove malware and backdoors, restore trusted files, and secure the site against another attack.

Discovering that your WordPress website has been hacked can be stressful, especially when the site is redirecting visitors, showing unexpected content, creating spam pages, or displaying a security warning.

Recovering a hacked WordPress website requires more than restoring the homepage or deleting a few suspicious files. A proper recovery process should identify how the compromise happened, contain the attack, investigate the website, remove malicious code and backdoors, restore trusted components, and strengthen the site before bringing it fully back into normal operation.

This guide explains how to recover a hacked WordPress website step by step and what website owners should check after a compromise.

What Does a Hacked WordPress Website Mean?

A WordPress website is considered hacked when someone gains unauthorized access and changes the website, its files, database, accounts, or hosting environment.

The visible symptoms can vary significantly. Some hacked websites are obviously defaced, while others continue to look normal to the owner but secretly serve spam, malicious redirects, or injected content to selected visitors.

A compromise may affect WordPress core files, plugins, themes, uploaded files, database records, administrator accounts, hosting credentials, or other parts of the hosting environment.

Common Signs That Your WordPress Website Has Been Hacked

Some of the most common signs of a compromised WordPress website include:

  • Unexpected redirects to unrelated websites
  • New pages or posts that you did not create
  • Unknown administrator accounts
  • Unexpected changes to website content
  • Suspicious PHP or JavaScript files
  • Google Search results containing spam pages
  • Browser or security warnings
  • Unexpected pop-ups or malicious scripts
  • Unusual server resource usage
  • Security scanner alerts
  • Users being redirected to different pages depending on their device or location

If you are not sure whether malware is present, start by checking the website carefully. My guide on how to check WordPress for malware covers common warning signs and inspection steps.

What to Do Immediately After Your WordPress Site Is Hacked

Before starting a full recovery, focus on limiting further damage.

1. Do Not Panic and Start Deleting Random Files

Deleting files without understanding what they do can break the website while leaving the actual backdoor or infection untouched.

Start by documenting what you are seeing and identifying when the problem first appeared.

2. Put the Website Into a Controlled State

If the compromised website is actively redirecting visitors, serving malicious content, or showing a security warning, consider temporarily restricting access while the investigation is performed.

The exact approach depends on the website and hosting environment. For a business website, keeping an infected site publicly accessible may expose visitors to additional risk.

3. Create a Backup for Investigation

Create a copy of the current website and database before making major changes whenever possible.

An infected backup should not automatically be considered safe for restoration. It can be useful as an investigation and recovery reference, but you should verify that files and database content are clean before using a backup in production.

Keep copies outside the public web directory and label them clearly so a compromised copy is not accidentally restored later.

How to Recover a Hacked WordPress Website

Once the website is contained, move through the recovery process systematically.

Step 1: Determine What Was Compromised

Start by identifying the scope of the compromise.

Check whether the issue is limited to WordPress or whether the hosting account, database, email accounts, or other websites on the same server may also be affected.

Review recent changes, file modification times, login activity, hosting logs, security alerts, and other available evidence.

Step 2: Identify the Possible Entry Point

A hacked website needs more than cleanup. You also need to understand how the attacker may have gained access.

Common possibilities include:

  • Vulnerable or outdated plugins
  • Vulnerable themes
  • Outdated WordPress core
  • Compromised administrator credentials
  • Weak passwords
  • Compromised hosting or FTP credentials
  • Existing backdoors
  • Insecure server configuration

Finding the entry point can be difficult when logs are limited, so avoid claiming a specific cause unless the available evidence supports it.

Step 3: Review Administrator Accounts

Open the WordPress user list and carefully review accounts with administrative privileges.

Remove accounts that are unauthorized or no longer required after confirming that they are not legitimate users.

Changing passwords for legitimate privileged users is also an important part of post-compromise recovery.

Step 4: Check WordPress Core Files

Compare WordPress core files against a clean copy of the same WordPress version where practical.

Unexpected modifications to core files can indicate malicious code, but not every modified file is necessarily malware. Customizations and legitimate changes should be considered before replacing files.

For files that should be identical to the official WordPress distribution, replacing compromised copies with trusted originals can be an effective recovery step.

Step 5: Inspect Plugins and Themes

Plugins and themes are common parts of a WordPress installation that require careful review after a compromise.

Check for:

  • Unexpectedly modified files
  • Recently added files
  • Unused plugins and themes
  • Outdated software
  • Plugins or themes from untrusted sources
  • Suspicious PHP code
  • Unexpected JavaScript

If a plugin or theme is no longer needed, removing it can reduce the website's attack surface.

Step 6: Inspect the Uploads Directory

The WordPress uploads directory deserves special attention during malware investigations.

Unexpected executable files or suspicious scripts in locations intended primarily for media uploads can indicate unauthorized activity.

Review suspicious files carefully before deleting them because some websites may legitimately use additional file types or custom functionality.

Step 7: Search the Database for Malicious Content

Cleaning the filesystem does not automatically clean a compromised database.

Review relevant database tables for:

  • Spam posts and pages
  • Injected scripts
  • Unexpected administrator settings
  • Malicious URLs
  • Injected JavaScript
  • Suspicious widget content
  • Unexpected options or configuration values

Database cleanup is especially important when the hack has created hundreds or thousands of spam pages.

Step 8: Find and Remove Backdoors

A backdoor is one of the biggest reasons a WordPress website can become infected again after an apparently successful cleanup.

A backdoor gives an attacker a way to regain access without using the original vulnerability.

Backdoors can be hidden inside legitimate-looking files, plugins, themes, uploads, or other writable locations. They may use obfuscated or encoded code to make detection more difficult.

Removing the visible malware while leaving a backdoor behind can result in another compromise.

Step 9: Reset Important Credentials

After a confirmed compromise, review and reset credentials that may have been exposed.

Depending on the environment, this may include:

  • WordPress administrator passwords
  • Hosting account passwords
  • FTP or SFTP credentials
  • SSH credentials
  • Database credentials
  • API keys or application credentials

Use strong, unique passwords and avoid reusing credentials between services.

Step 10: Update WordPress and Extensions

Once the website has been cleaned, update WordPress core, plugins, and themes to supported versions.

Remove software that is unnecessary, abandoned, or no longer maintained where appropriate.

Keeping the software current reduces exposure to known vulnerabilities, although updates alone cannot guarantee that a website will never be compromised.

Should You Restore a Backup Instead?

A clean, verified backup can sometimes provide an efficient recovery path, especially when the compromise is extensive and a known-good backup is available.

However, restoring a backup without understanding when the compromise occurred can restore the malware as well.

Before restoring a backup, determine:

  • When the website was likely compromised
  • Whether the backup predates the compromise
  • Whether the backup itself has been verified
  • Whether the original vulnerability has been fixed
  • Whether credentials need to be changed

A backup is a recovery tool, not a substitute for security investigation.

How to Prevent the WordPress Website From Being Hacked Again

Recovery should end with security improvements that reduce the likelihood of another compromise.

Use Strong Authentication

Protect administrator accounts with strong unique passwords and two-factor authentication where available.

Keep WordPress Updated

Regularly update WordPress core, plugins, and themes and remove components that are no longer needed.

Limit Administrator Access

Give users only the permissions they need. Avoid keeping unnecessary administrator accounts active.

Use Reliable Backups

Maintain regular backups and periodically verify that the backups can actually be restored.

Add Security Monitoring

Security monitoring can help identify suspicious file changes, login activity, malware indicators, and other unusual behavior before a small problem becomes a larger incident.

Consider Firewall and Cloud Protection

A properly configured firewall and traffic protection layer can provide another layer of defense between attackers and the WordPress application.

For websites that need additional traffic filtering and protection, see the Cloudflare Security service.

What Happens If Google Has Already Flagged the Website?

A hacked website may develop search visibility problems if malicious pages, spam, or harmful content are discovered by search engines.

If Google Search Console reports a security issue, cleaning the website should come before requesting a review.

After the compromise has been addressed, verify that malicious content is gone and follow the appropriate Google review process for the reported issue.

If the website has been placed on a security blacklist, the recovery process may require additional investigation and verification. You can learn more about Google Blacklist Removal if this applies to your situation.

How to Tell If a Hacked WordPress Website Is Really Clean

A website looking normal in the browser does not prove that the compromise has been completely removed.

After cleanup, verify the following:

  • Known malicious files have been removed
  • Unauthorized users have been reviewed
  • Suspicious database content has been cleaned
  • Backdoors have been investigated
  • WordPress and extensions are updated
  • Passwords and sensitive credentials have been changed
  • Important pages work correctly
  • Security scans no longer identify known threats
  • Search Console security issues have been addressed where applicable
  • Monitoring and backups are working

For a deeper review of the site's security posture after recovery, a WordPress Security Audit can help identify remaining weaknesses.

Why Professional WordPress Recovery Can Be Worthwhile

Simple website problems can sometimes be handled by an experienced site administrator. More complex compromises require a careful investigation because the visible symptoms may represent only part of the infection.

Professional recovery can be particularly useful when a website has:

  • Multiple infected files
  • Database injections
  • Unknown administrator accounts
  • Hidden backdoors
  • SEO spam
  • Repeated reinfections
  • Google security warnings
  • Multiple websites on the same hosting account

The objective should not be to make the website look normal temporarily. The goal is to understand the compromise, remove the malicious components, secure the environment, and reduce the risk of another incident.

Frequently Asked Questions

Can a hacked WordPress website be recovered?

Yes. Many hacked WordPress websites can be recovered when the compromise is properly investigated and the malicious files, database changes, unauthorized access, and underlying security weaknesses are addressed.

Should I delete my entire WordPress website after it is hacked?

Not necessarily. Completely deleting a website may destroy useful evidence and legitimate content. The appropriate recovery method depends on the extent of the compromise and whether a clean, verified backup is available.

Is restoring a backup enough to recover a hacked WordPress site?

Not always. The backup may contain the same malware, or the vulnerability that allowed the original compromise may still exist. A restored website should still be reviewed and secured.

How do I know if my WordPress site has a backdoor?

Backdoors can be difficult to identify because they may be hidden inside legitimate-looking files or use obfuscated code. File comparison, malware analysis, access review, and investigation of suspicious changes can help identify them.

Will changing my WordPress password fix a hacked website?

Changing passwords is an important recovery step, but it does not remove malware or backdoors. A compromised website should be investigated and cleaned separately.

How can I prevent my WordPress website from being hacked again?

Keep WordPress and extensions updated, use strong authentication, limit privileged access, maintain reliable backups, monitor the website, remove unnecessary software, and address the vulnerability or compromised credentials that caused the original incident.

Need Help Recovering a Hacked WordPress Website?

If your WordPress website has been hacked, the priority is to contain the compromise, investigate what changed, remove malicious code and backdoors, and secure the website before returning it to normal operation.

I provide Hacked WordPress Recovery for websites that need professional investigation, cleanup, and security recovery.

If your website is currently compromised, avoid making random changes that could destroy evidence or make the recovery more difficult. Start with a controlled investigation and work toward a clean, secure installation.

Free security check

Worried your site is infected?

Get a free security assessment — I'll tell you if your WordPress site is compromised and exactly what it needs. No obligation.

Worried about your own site?