Security · · 31 min read

How to Fix a Hacked WordPress Website Without Losing Data: Complete Recovery Guide for 2026

How to fix a hacked WordPress site

You open your website and something is wrong. Google is showing a red warning screen. Visitors say they’re being redirected to strange pages. Your homepage looks different. Or you simply can’t log in to wp-admin anymore.

Your first instinct might be to delete everything and reinstall WordPress from scratch.

Don’t.

That instinct — while understandable — can destroy the evidence that shows how the attacker got in, wipe out content and customer data you actually need, and leave the original vulnerability wide open for the exact same attack to happen again next week.

This guide walks through a systematic recovery process built around one principle: preserve evidence and data first, then clean and recover the site methodically. By the end, you’ll know how to confirm you’ve actually been hacked, protect your data before touching anything, find and close the entry point, clean infected files and the database, recover your accounts, and get your rankings and traffic back — without losing the site you built.

Quick Emergency Recovery Checklist

If you’re in the middle of an active incident right now, start here. The exact order can shift depending on your situation — but nothing on this list should be skipped.

  • Don’t delete the entire website
  • Don’t overwrite the infected site immediately
  • Take a forensic backup/snapshot of the site in its current (infected) state
  • Contact your hosting provider
  • Secure your hosting account (change password, check for unfamiliar users)
  • Change compromised passwords — but see the warning below about doing this from a clean device
  • Revoke active WordPress sessions
  • Preserve server, access, and error logs before they rotate out
  • Identify suspicious administrator accounts
  • Scan files for malware and backdoors
  • Scan the database for injected content
  • Identify the initial attack vector — not just the symptom
  • Remove the malware completely
  • Patch the actual vulnerability that let the attacker in
  • Restore only components you’ve verified are clean
  • Rotate every secret and credential connected to the site
  • Monitor the site closely for weeks after cleanup

30 Warning Signs Your WordPress Website May Be Hacked

Some compromises are obvious. Many are quiet for weeks before you notice — the attacker often wants your site to keep functioning normally so it stays useful to them.

Warning SignWhat It May Indicate
Unexpected redirects for visitorsInjected redirect malware, often only triggered for search-engine bots or mobile users
Strange popups or adsInjected JavaScript or a malicious ad-injection script
Unknown administrator accountsFull account takeover — attacker created persistent access
Plugins you didn’t installBackdoor disguised as a legitimate plugin
Modified theme filesDirect file-level compromise, often via a vulnerable upload path
Unfamiliar PHP files in uploadsWeb shell or backdoor dropped through a file upload vulnerability
Altered homepage contentDefacement — a visible sign of a deeper compromise
Spam pages appearing on your domainSEO spam injection, often in a hidden or randomly-named directory
Foreign-language keyword spam in search resultsClassic SEO spam injection technique targeting search visibility, not your visitors
Pharmaceutical or casino spam in search resultsCommon monetized spam campaigns injected into indexed pages
Hidden links in page sourceLink injection used to manipulate another site’s search rankings
Google Search Console security warningGoogle has detected malware or spam associated with your site
Browser “dangerous site” warningsYour site is flagged in Safe Browsing or a similar blocklist
Sudden traffic spikes or dropsCould indicate spam pages being indexed, or a redirect diverting real visitors
Unexpected server load/CPU usageCryptocurrency mining, spam-sending, or brute-force scripts running on your server
Unknown cron jobsScheduled persistence mechanism re-injecting malware after cleanup
Suspicious JavaScript in page sourceInjected script performing redirects, ad fraud, or credential theft
Your domain sending spam emailCompromised SMTP configuration or a mail-sending script planted on the server
Your password no longer worksAccount takeover — the attacker changed it
Security plugin disabled or missingAttacker disabled it to avoid detection
Modified .htaccess fileServer-level redirect or access-control tampering
Suspicious rows in the databaseInjected spam content or malicious scripts stored directly in post/option data
Unknown API keys in settingsAttacker-configured integration used for data exfiltration or persistence
Unusual login activity/timesCredential stuffing or a successful unauthorized login
SEO titles/meta descriptions changedSpam content injected directly into indexed metadata
Strange URLs in your sitemapSpam pages being generated and submitted to search engines automatically
Redirects that only happen on mobileCloaking technique used to hide the attack from desktop admins while targeting real visitors
Spam pages appearing in Google’s indexConfirms spam content has already been crawled and indexed
Hosting account suspendedYour host detected malicious activity originating from your account

What to Do in the First 30 Minutes

Speed matters, but precision matters more. Moving too fast in the wrong direction — like restoring a random old backup — can make recovery harder, not easier.

0–5 minutes: Contain, don’t destroy

Confirm what you’re actually seeing. Don’t touch files yet. If the site is actively harming visitors (serving malware downloads, phishing pages), consider putting it in maintenance mode or temporarily taking it offline at the hosting level — not deleting anything.

5–15 minutes: Preserve evidence

Take a full snapshot of the site exactly as it is right now — files and database — even though it’s infected. This becomes your forensic copy. You’ll investigate it separately from the live site.

15–30 minutes: Secure access from a clean device

Change your hosting and WordPress passwords — but do this from a device you’re confident isn’t compromised. If the breach may have involved a keylogger or malware on your own computer, changing passwords from that same device just hands the new password to the attacker too.

First hour: Contact your host, preserve logs

Reach out to your hosting provider — many have security teams who can see server-level activity you can’t, and they may already recognize the specific compromise pattern. Ask them to preserve access/error logs before automatic rotation deletes them.

First 24 hours: Investigate before you clean

Resist the urge to start deleting suspicious-looking files immediately. Spend this window identifying the entry point and scope of the compromise. Cleaning without understanding what happened is how sites get reinfected within days.

Why You Should Back Up a Hacked Site Before Cleaning It

This feels counterintuitive — why back up something infected? Because you need a reference point. If you clean too aggressively and break something, or discover later you missed a piece of the malware, that snapshot lets you go back and check exactly what was there.

Back up everything relevant, not just the parts that look obviously infected:

  • Full database export
  • Entire wp-content directory (themes, plugins, uploads)
  • wp-config.php
  • .htaccess (or nginx configuration, if you have server access)
  • Server access logs and error logs
  • A hosting-level snapshot, if your host offers one

Four different kinds of backup, and why the distinction matters

Backup TypePurposeSafe to Restore Directly?
Clean backupA verified-good copy from before the compromiseYes, once you’ve confirmed the vulnerability that led to the hack is also fixed
Suspected infected backupA recent backup that may already contain the malwareNo — restoring it can bring the infection right back
Forensic copyThe site exactly as found, for investigationNo — this is for analysis, not restoration
Disaster-recovery backupYour ongoing off-site backup strategy for the futureDepends entirely on when it was taken relative to the compromise

A backup existing is not the same as a backup being safe. If your automated backups have been running since before the hack, several of your most recent ones may already contain the exact malware you’re trying to remove. Restoring one blindly can put you right back where you started.

How to Recover WordPress Without Losing Posts, Pages, Images, and Users

Most of what matters to you as a site owner lives in one of two places, and they need to be handled differently during recovery.

ComponentWhere It LivesCan It Be Replaced?Recovery Considerations
Posts, pages, commentsDatabase (wp_posts)No — must be preserved and cleaned in placeCheck for injected spam content mixed into legitimate posts
UsersDatabase (wp_users, wp_usermeta)Legitimate users: no. Rogue accounts: remove themAudit every account before assuming it’s legitimate
Settings/optionsDatabase (wp_options)No — but scan carefully, this table is a common injection targetCheck for malicious entries in autoloaded options
WooCommerce orders/customersDatabase (custom tables + postmeta)No — critical business dataTreat with extra care; may involve privacy obligations
Media/imagesFilesystem (wp-content/uploads)No — but scan thoroughly for hidden malicious filesCheck for PHP files disguised among image files
ThemesFilesystem (wp-content/themes)Yes, if not custom — reinstall from official sourceCustom themes need manual review, not blind replacement
PluginsFilesystem (wp-content/plugins)Yes — always reinstall from official sourcesNever trust an existing plugin folder; replace entirely
WordPress coreFilesystem (wp-admin, wp-includes, root files)Yes — always replace with fresh official filesDo not keep old core files “to be safe”
wp-config.phpFilesystem (root)Rebuild carefully, don’t blindly reuseContains credentials and secrets — rotate everything referenced in it

The general rule: anything that’s just “software” (core, plugins, themes from official sources) should be replaced entirely, not cleaned. Anything that’s genuinely your data (database content, custom code, uploads) needs to be preserved and carefully inspected instead.

Find Out How the Hacker Got In

Removing malware without identifying the entry point is the single most common reason WordPress sites get reinfected. If you don’t close the door, cleaning the mess behind it doesn’t stop the next visit.

The most common entry points, in roughly descending order of frequency:

  • Vulnerable plugin — by far the most common cause of WordPress compromises
  • Vulnerable theme — especially premium themes that haven’t been updated
  • Outdated WordPress core — missing security patches from newer releases
  • Stolen administrator credentials — often from an unrelated data breach where the password was reused
  • Brute-force attack — automated password guessing against an unprotected login form
  • Credential stuffing — automated attempts using real leaked email/password pairs
  • Compromised hosting account — direct file access without touching WordPress at all
  • Vulnerable custom code — a custom plugin or theme built without proper input validation
  • Insecure file upload feature — a form or plugin that doesn’t validate file type by content
  • SQL injection — unsanitized input reaching a raw database query
  • XSS leading to session theft — a stored script that hijacked an administrator’s session
  • Privilege escalation — a lower-level account exploiting a flaw to gain admin capabilities
  • Exposed API credentials — keys committed to a public repository or left in an accessible file
  • Leaked SSH/SFTP credentials — direct server access via a compromised credential
  • Compromised third-party service — a connected integration or supply-chain compromise
  • Abandoned plugin — known vulnerability that was never patched because development stopped
  • Nulled/pirated plugin or theme — a backdoor installed intentionally, from day one

A typical attack chain

Vulnerable Plugin
   ↓
Exploit (automated scanner finds and triggers the flaw)
   ↓
Initial Access (file write or authentication bypass)
   ↓
Backdoor (web shell dropped for persistent remote access)
   ↓
Administrator / Server Access (privilege escalation or credential harvest)
   ↓
Malicious Code (injected into files, database, or both)
   ↓
SEO Spam / Redirect / Data Theft (the actual monetization)
   ↓
Persistence (cron jobs, rogue admin accounts, hidden backdoors — so cleanup doesn't stick)

Work backward through your logs and file timestamps to find where this chain started. The first modified file, the first unfamiliar login, or the first unusual request in your access logs is usually your answer.

Check WordPress Users

Account takeover and rogue admin creation are common enough that user auditing deserves its own step, separate from file and database cleanup.

Go through every user with elevated capabilities and confirm you recognize them and their access level is appropriate. Pay attention to:

  • Administrator accounts you don’t remember creating
  • Usernames that look auto-generated or slightly off from your naming convention
  • Recently created accounts with no legitimate activity history
  • Existing legitimate accounts with recently changed email addresses (a common takeover technique — change the email, then reset the password)
  • Active sessions that don’t match your team’s known devices/locations
  • Application passwords you don’t recognize
  • Any OAuth/SSO connections you didn’t authorize

To pull a quick list of every administrator-level user for review, this WP-CLI command is faster and safer than scrolling through the dashboard on a possibly-compromised admin session:

wp user list --role=administrator --fields=ID,user_login,user_email,user_registered

Remove any account you can’t positively confirm is legitimate, then force a password reset and session revocation for everyone who remains.

Check WordPress Files

You’re looking for anything that shouldn’t be there, and anything that’s been modified when it shouldn’t have changed. Focus on:

  • wp-content/plugins — compare against what you actually installed
  • wp-content/themes — check for unfamiliar theme folders or modified files in your active theme
  • wp-content/uploads — this directory should never contain PHP files
  • wp-config.php — check modification date and contents
  • .htaccess — check for injected redirect rules
  • wp-includes and wp-admin — these should exactly match official WordPress core files

Common red flags inside PHP files include obfuscated code, unexpected use of eval(), base64_decode(), or gzinflate() to hide payloads, preg_replace() used with the (long-deprecated and dangerous) /e modifier, code that fetches and executes content from a remote URL, suspiciously named files sitting alongside legitimate ones, PHP files anywhere inside the uploads directory, unfamiliar admin-area scripts, and injected <script> tags or hidden iframes in theme files.

Important context: not every use of base64_decode() or eval() is malware. Some legitimate plugins use these functions for entirely normal reasons — caching, licensing checks, or data compression. The red flag is the combination: obfuscated code you can’t explain, in a file that shouldn’t have it, doing something you didn’t authorize. When in doubt, compare the file against the plugin’s original source rather than judging a single function call in isolation.

A fast way to compare your core files against the official versions is WordPress’s built-in checksum verification:

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

Any file flagged as modified deserves a closer look — it doesn’t automatically mean malware, but unexplained modifications to core files are one of the strongest indicators of compromise you’ll find.

How to Find Malware Inside the WordPress Database

File-based cleanup alone misses a huge category of infections. Malicious content frequently lives directly in the database, and a site can look completely clean at the file level while still serving spam or redirects from injected database content.

Check these tables specifically:

  • wp_options — especially autoloaded options; a common place to hide malicious scripts or redirect URLs, including the siteurl and home values themselves
  • wp_posts — spam content injected into existing posts/pages, or entirely new hidden spam pages
  • wp_postmeta — malicious scripts hidden in metadata fields
  • wp_users / wp_usermeta — rogue accounts and capability manipulation
  • WooCommerce tables — order and customer data integrity
  • Custom plugin tables — anywhere a plugin stores its own data

Watch specifically for injected JavaScript or iframe tags inside post content, spam links hidden with CSS (like display:none) inside legitimate-looking posts, a siteurl or home option pointing somewhere unexpected, options with names that mimic legitimate plugin settings but contain executable code, and unfamiliar scheduled tasks stored in the wp_options cron array.

Before running any cleanup query, export a full database backup. Careless SQL — especially broad UPDATE or DELETE statements without a precise WHERE clause — can silently damage legitimate content. Search first, verify what you’re looking at, and only then remove it, ideally starting with the narrowest possible match.

Common Types of WordPress Malware

Malware TypeWhat It DoesTypically FoundDetection Approach
PHP backdoor / web shellGives the attacker ongoing remote command executionUploads directory, plugin folders, sometimes disguised as a core fileFile integrity scan, checksum comparison, manual code review
SEO spam injectionInserts spam keywords/links to manipulate search rankingswp_posts, wp_options, theme footer filesSearch database content, check indexed pages via Search Console
Redirect malwareSends visitors (often only bots or mobile users) to another site.htaccess, theme header files, wp_optionsTest from multiple devices/user agents, check .htaccess rules
Malicious JavaScript injectionRuns code in visitors’ browsers — ads, redirects, credential theftTheme files, wp_posts content, injected script tagsView page source, check for unfamiliar external script sources
Phishing pagesHosts fake login pages to harvest credentials from other servicesHidden directories, often unlinked from the visible siteServer file listing, Search Console coverage report
Admin account takeoverPersistent, privileged access disguised as a normal accountwp_usersManual user audit against known team members
Malicious cron jobsRe-injects malware or maintains persistence automaticallywp_options cron array, server-level crontabwp cron event list, server crontab review
Database injectionStores malicious scripts or content directly in the databasewp_options, wp_postmeta, custom tablesTargeted database search for script tags and suspicious patterns
Credit-card skimmerCaptures payment details entered on checkout formsWooCommerce checkout templates, injected JavaScriptReview checkout page source, compare against gateway documentation
Cryptocurrency minerUses server CPU resources for mining, degrading performanceServer-level processes, sometimes plugin-disguisedUnusual CPU load, hosting provider resource alerts

Clean WordPress Safely: The Step-by-Step Workflow

  1. Preserve an infected copy — your forensic reference point, kept separate from the live site
  2. Secure accounts — hosting, WordPress, database, all rotated from a clean device
  3. Identify the entry point — don’t skip this to save time; it determines everything else
  4. Replace WordPress core — download fresh files directly from WordPress.org, don’t reuse existing core files
  5. Replace compromised plugins — reinstall from official sources rather than trying to “clean” existing plugin files
  6. Replace compromised themes — same principle; for custom themes, review code manually instead
  7. Inspect uploads — this directory should never contain executable PHP; anything that isn’t a legitimate media file needs scrutiny
  8. Clean the database — remove injected content, verify options tables, check for rogue scheduled tasks
  9. Remove malicious users — anything you can’t positively verify as legitimate
  10. Remove persistence mechanisms — rogue cron jobs, scheduled tasks, hidden backdoors that would re-infect a freshly cleaned site
  11. Rotate secrets — database credentials, authentication keys/salts, API keys, application passwords
  12. Update everything — core, plugins, themes, PHP version — to close the vulnerability that was exploited
  13. Re-scan — a full malware and file-integrity scan after cleanup, not just before
  14. Monitor — closely, for at least several weeks, since a missed piece of persistence can quietly reinfect a “clean” site

Replacing core, plugin, and theme files entirely — rather than manually editing them line by line — is usually the safer path. It’s extremely difficult to be certain you’ve found every single modification inside a large codebase by manual review alone, and a fresh official copy guarantees the code matches what it’s supposed to.

How to Reinstall WordPress Without Losing Your Content

“Reinstalling WordPress” sounds like it might wipe everything — it doesn’t have to, if you understand what actually gets replaced versus what stays.

ComponentWhat Happens on Reinstall
Database (posts, pages, users, settings)Untouched by a core reinstall — your content lives here, separately from the files being replaced
wp-content (themes, plugins, uploads)Not touched by the core reinstall process itself — but you should still inspect and individually replace plugins/themes
UploadsPreserved — but scan carefully, since this is a common place for hidden malicious files
ThemesNot automatically replaced — reinstall official ones manually, review custom ones by hand
PluginsNot automatically replaced — reinstall each from the official source individually
wp-config.phpPreserved by default — but this is exactly where you should be rotating credentials, not blindly keeping it as-is
Custom code (child themes, custom plugins)Preserved — but requires manual security review since it wasn’t written by a vetted third party

The critical thing to understand: reinstalling WordPress core does not automatically remove malware. If malicious files remain in wp-content, or malicious content remains in the database, a core reinstall does nothing to touch them — the site can look “reinstalled” and still be fully compromised. Core replacement is one step in the process, not the whole process.

Cleaning wp-content/uploads

The uploads directory gets special attention for one simple reason: it should never contain executable PHP files, and yet it’s one of the most common places attackers drop them, because many sites don’t expect to check there.

Look for PHP files mixed in among your images and media, files with double extensions designed to slip past naive checks (like photo.jpg.php), JavaScript files that don’t correspond to anything you installed, hidden files (starting with a dot) that don’t belong there, and files with modification timestamps that don’t match your actual upload history.

Even legitimate-looking image files are worth checking — some malware is embedded inside a valid image file’s metadata and combined with a separate script that reads and executes it. Don’t delete files indiscriminately based on appearance alone; when something looks suspicious but you’re not certain, isolate it (move it outside the web root) rather than permanently deleting it, so you retain the option to investigate further if something breaks.

Securing wp-config.php After a Hack

This file holds your database credentials and authentication secrets — treat it as compromised by default until proven otherwise, since it’s one of the highest-value targets on the entire server.

After any confirmed or suspected compromise:

  • Change your database password and update it here
  • Regenerate all authentication keys and salts (WordPress.org provides a secret-key generator for this)
  • Set DISALLOW_FILE_EDIT to true to prevent file editing from the dashboard
  • Set WP_DEBUG_DISPLAY to false in production so errors don’t leak file paths to visitors
  • Verify file permissions aren’t overly permissive
  • Where your hosting supports it, move credentials to environment variables instead of hardcoding them in the file

Rotating authentication keys and salts immediately invalidates every existing session — including the attacker’s, if they had one — which makes this one of the highest-value single actions in the entire recovery process.

Cleaning .htaccess and Server Configuration

Attackers frequently use server-level configuration for persistence and redirects, precisely because site owners rarely think to check there. This applies to .htaccess on Apache, equivalent server blocks on nginx, PHP configuration files, and cron entries at the server level (separate from WordPress’s own cron system).

Watch for redirect rules you didn’t add, rewrite rules pointing to unfamiliar domains, and directives that hide certain files or directories from directory listings for suspicious reasons. Preserve a copy of the current configuration before modifying anything — if a legitimate plugin or your hosting environment depends on a specific rule, removing it blindly can break the site in a different way.

WordPress Malware Scanners: What They Catch and What They Miss

MethodStrengthLimitationBest Use
Plugin-based scannerEasy to run, integrated with the dashboard, good for ongoing monitoringRuns inside the potentially-compromised environment; limited server-level visibilityRegular scheduled scanning, early warning
Server-level scannerSees the full filesystem, not limited by PHP execution contextRequires hosting/server access; more technical to configureDeeper investigation during active incident response
Remote/external scannerSees the site the way a visitor or Google doesCan’t see server-side code or database content directlyConfirming visible symptoms like redirects or defacement
File integrity monitoringDetects unauthorized changes to core/plugin/theme files quicklyOnly useful if a clean baseline was established beforehandOngoing prevention, not initial incident discovery
Hosting-provided malware scanningOften has visibility other tools don’t, integrated with the host’s own security teamCoverage and quality vary significantly by hostFirst call during an active incident

No scanner catches everything. Automated tools are pattern- and signature-based, which means novel or custom-written malware can slip past them. Treat scanning as one input into your investigation, not a final verdict — a clean scan result doesn’t mean the site is definitely clean, especially with a sophisticated or targeted compromise.

Security Plugin vs. Manual Cleanup vs. Professional Help

ApproachWhen It Makes Sense
Security plugin cleanupSimple, well-understood infections on sites where you’re comfortable following technical steps
Manual investigationDevelopers/agencies comfortable reading PHP and SQL directly, or cases the automated tools clearly missed
Professional malware removal serviceBusiness-critical sites, WooCommerce stores with customer data, repeated reinfection, or when you simply lack the time/expertise to do it safely
Hosting provider assistanceAlways worth contacting early — many hosts offer free guidance or paid cleanup, and they have visibility you don’t

There’s no universally “right” choice here — it depends on the sensitivity of the data involved, your technical comfort level, and how much downtime and risk you can tolerate. For any site handling customer or payment-adjacent data, professional help is worth strongly considering even if the infection looks minor.

What Happens to Google Rankings After a WordPress Hack?

This is often the part that worries site owners most, and reasonably so — a hack can affect your visibility in several distinct ways at once.

  • Malware warnings in browsers can scare away visitors even after you’ve fixed the underlying issue, until the warning is cleared
  • Hacked spam pages get crawled and indexed, sometimes outranking your legitimate content for irrelevant spam terms
  • Redirects aimed at search bots specifically can get your site associated with the destination spam site in Google’s systems
  • A compromised sitemap can actively submit spam URLs to search engines
  • Changed titles/meta descriptions alter how your legitimate pages appear in search results
  • Search Console security issues flag the domain as compromised until you request and pass a review
  • Manual actions (a separate, human-reviewed penalty) can apply if Google’s team determines the site violated guidelines, which is distinct from an automated security flag
  • Crawl errors and canonical problems can emerge from injected pages competing with your real content structure

A safe SEO recovery process

  1. Fully clean the website — files and database
  2. Fix the underlying vulnerability that allowed the compromise
  3. Verify site ownership in Google Search Console if you haven’t already
  4. Inspect the Security Issues report for specific flagged URLs
  5. Remove any malicious pages that were created, where you’re certain they’re not legitimate content
  6. Request a security review once you’re confident the site is genuinely clean — not before
  7. Restore a legitimate, accurate sitemap
  8. Monitor indexing in Search Console for unexpected URLs reappearing
  9. Monitor rankings and traffic over the following weeks

Be realistic: recovery timing varies, and there’s no guarantee rankings return to exactly where they were or on a fixed timeline. What you can control is doing a genuinely complete cleanup and passing Google’s review — that’s the foundation recovery depends on.

How to Recover From a Google Security Warning

Inside Google Search Console, two related but different reports matter here:

  • Security Issues — Google’s automated systems detected malware, hacked content, or phishing associated with your site. This is what triggers the red browser warning visitors see.
  • Manual Actions — a human reviewer at Google determined your site violates search guidelines. This is separate from an automated malware flag and requires its own reconsideration request.

Once you’ve completed cleanup: review the Security Issues report for the specific URLs and issue types Google flagged, use URL Inspection to confirm those pages are now clean, make sure your sitemap reflects only legitimate content, and only then submit the review request. Submitting before cleanup is genuinely complete typically results in a failed review and a longer wait before you can try again.

WooCommerce Hack Recovery

A compromised store carries extra weight because of what’s at stake: customer accounts, order history, and anything connected to payment processing.

In addition to the general recovery process, specifically review:

  • Customer account data for unauthorized changes or export activity
  • Order information for tampering
  • Any API keys or webhooks connected to your payment gateway — rotate them
  • Payment gateway credentials — coordinate with your provider, don’t assume WordPress-level cleanup is sufficient
  • Admin and staff accounts with store-management access
  • Checkout page templates and scripts for injected skimming code
  • Database integrity for order and customer tables specifically
  • Your privacy obligations regarding any potentially affected customer data

WordPress-level recovery and payment-provider security are separate responsibilities. If you use a hosted checkout or tokenized payment fields, your payment processor handles most of the actual card-data security — but you’re still responsible for everything WordPress-side: who could access order data, whether admin accounts were compromised, and whether the site itself is genuinely clean. If there’s any possibility payment credentials or tokens were exposed, contact your payment provider directly — don’t assume a WordPress cleanup alone resolves that risk.

If Customer Data May Have Been Exposed

This is a serious enough scenario that it deserves a careful, deliberate approach rather than guesswork.

  • Investigate logs to understand what was actually accessed, not just what’s theoretically possible
  • Determine what data may have been exposed — customer emails, addresses, order history, or anything more sensitive
  • Preserve evidence before continuing cleanup, in case you need it later
  • Contact your hosting provider or a security professional for help assessing scope, especially if you’re uncertain
  • Consult a legal or privacy professional about notification obligations — these vary by jurisdiction and the type of data involved, and this guide can’t give you a legal conclusion on your specific situation
  • Communicate appropriately with affected users once you understand the actual scope, based on that professional guidance
  • Rotate every credential connected to the affected systems
  • Document the incident — what happened, when, how it was found, and what was done — both for your own records and any obligations you may have

Change All Credentials After Cleanup

Changing only the WordPress admin password is one of the most common — and most incomplete — responses to a hack. Rotate everything connected to the site:

  • WordPress admin and user passwords
  • Hosting account password
  • Database password (updated in wp-config.php)
  • FTP/SFTP credentials
  • SSH keys
  • API keys for any connected service
  • WordPress application passwords
  • CDN credentials
  • SMTP credentials used for sending mail
  • Payment API credentials, in coordination with your provider
  • Any third-party integration tokens

If the attacker had server-level access at any point, a password alone may not be enough — SSH keys, for instance, need to be regenerated and the old ones revoked, not just protected with a new password on top of them.

Complete WordPress Security Hardening Checklist After a Hack

  • Update WordPress core, plugins, and themes — and keep them updated going forward
  • Enable two-factor authentication on every administrator account
  • Apply the principle of least privilege to every user role
  • Enforce strong, unique passwords via a password manager
  • Confirm your hosting environment is genuinely secure — current PHP version, proper isolation
  • Put a real WAF in front of the site, ideally cloud/edge-based
  • Set up ongoing malware monitoring, not just one-time scanning
  • Establish automated backups going forward
  • Ensure at least one backup copy is stored off-site
  • Actually test backup restores periodically
  • Enable file integrity monitoring with a fresh, verified-clean baseline
  • Add login rate limiting and lockout protection
  • Configure security headers appropriately for your site
  • Enforce HTTPS sitewide
  • Audit every plugin for maintenance status and vulnerability history
  • Audit your theme the same way, especially if it’s a premium theme
  • Set up alerts for newly disclosed vulnerabilities in your installed software
  • Review server-level security settings, not just WordPress settings
  • Keep and review logs regularly, rather than only during an incident
  • Set up alerting so you find out about problems in hours, not weeks

30 Common Mistakes After a WordPress Hack

  1. Deleting the entire website instead of investigating first
  2. Restoring an infected backup without checking it first
  3. Only changing the admin password and stopping there
  4. Ignoring hosting account credentials entirely
  5. Ignoring malware that lives in the database, not just files
  6. Ignoring unfamiliar cron jobs
  7. Keeping nulled or pirated plugins after cleanup
  8. Reinstalling the exact same vulnerable plugin version
  9. Not rotating API keys connected to the site
  10. Not checking for unknown administrator accounts
  11. Not reviewing server logs at all
  12. Not updating the PHP version
  13. Never actually testing whether backups restore correctly
  14. Assuming a security plugin scan means the site is fully clean
  15. Ignoring Google Search Console entirely during recovery
  16. Never identifying the original vulnerability that was exploited
  17. Cleaning files but skipping wp-config.php credential rotation
  18. Assuming HTTPS alone means the site is secure
  19. Trusting file modification dates alone without checking content
  20. Deleting suspicious files without preserving a copy first
  21. Skipping a user audit because “nothing looks different”
  22. Not checking application passwords and OAuth connections
  23. Restoring the site before the vulnerability is actually patched
  24. Not monitoring closely in the weeks after cleanup
  25. Assuming a single scan is sufficient instead of scanning again after cleanup
  26. Not informing team members who also have login access
  27. Forgetting to check staging or development copies of the site for the same issue
  28. Not documenting what happened, making the next incident harder to diagnose
  29. Ignoring warning signs for weeks before taking action
  30. Handling a business-critical or customer-data breach entirely alone without professional input

Recovery Scenarios

Scenario 1: Homepage replaced by hacker

Likely cause: A file-write vulnerability or stolen credentials gave direct access to modify theme files or the homepage content.
Immediate response: Take a forensic snapshot, don’t panic-restore yet.
Recovery approach: Identify exactly what was modified, check for additional hidden changes beyond the visible defacement, then restore from clean source files.
Prevention: File integrity monitoring would have caught this within minutes instead of whenever a visitor noticed.

Scenario 2: Website redirects visitors to spam websites

Likely cause: Injected redirect code in .htaccess, theme files, or database options — often targeting only mobile users or search bots to stay hidden from admins.
Immediate response: Test the site from multiple devices and user agents to understand the actual scope.
Recovery approach: Check .htaccess, theme header/footer files, and wp_options for injected redirect logic; remove and verify from a clean device.
Prevention: A WAF filtering malicious requests before they reach WordPress, plus regular file integrity checks.

Scenario 3: Unknown administrator account created

Likely cause: Successful credential compromise or a privilege-escalation vulnerability.
Immediate response: Remove the account, but first check what it did while active (posts created, settings changed, plugins installed).
Recovery approach: Full user audit, session revocation for everyone, and password/2FA reset across all real accounts.
Prevention: 2FA on all administrator accounts and monitoring for new user creation.

Scenario 4: Google shows a security warning

Likely cause: Malware or spam content that Google’s crawlers have already detected and indexed.
Immediate response: Don’t request a review yet — clean the site fully first.
Recovery approach: Full cleanup, then follow the SEO/Search Console recovery process described above.
Prevention: Regular scanning catches this before Google does.

Scenario 5: WooCommerce store compromised

Likely cause: Any of the standard entry points, but with higher stakes due to customer/order data.
Immediate response: Treat as a potential data-exposure incident from the start, not just a technical cleanup.
Recovery approach: Full WordPress recovery process plus payment-provider coordination and customer-data assessment.
Prevention: Strict least-privilege for staff accounts, API key rotation discipline, and dedicated store monitoring.

Scenario 6: Website infected but the database absolutely must be preserved

Likely cause: Any entry point, but the business can’t tolerate content/order loss.
Immediate response: Full database backup before any cleanup activity begins.
Recovery approach: Clean the database in place using targeted, verified queries rather than restoring an older version — replace files entirely, but treat the database as something to carefully disinfect, not discard.
Prevention: Frequent, tested, off-site database backups specifically, on a schedule that matches how often the data actually changes.

WordPress Recovery Decision Tree

Is the site hacked?
  → Confirm with concrete evidence (warning signs, scans, logs) — not just a hunch
       ↓
Can you access wp-admin?
  → Yes: proceed with in-dashboard investigation carefully
  → No: use hosting file manager / SFTP / database access directly
       ↓
Is the server itself compromised (not just WordPress)?
  → Yes: involve your hosting provider immediately, this is beyond a WordPress-only fix
  → No: proceed with WordPress-level cleanup
       ↓
Do you have a clean, verified backup from before the compromise?
  → Yes: it's a candidate for restoration, but only after the vulnerability is identified and patched
  → No: manual cleanup is required
       ↓
Is customer or sensitive data potentially affected?
  → Yes: treat as a data-exposure incident — involve legal/privacy guidance
  → No: standard technical cleanup process applies
       ↓
Can the infection be clearly isolated and understood?
  → Yes: manual cleanup or backup restoration (post-patch) is reasonable
  → No / uncertain / repeated reinfection: bring in professional incident response

Backup Strategy After Recovery

Once the immediate incident is resolved, your backup strategy needs to be rebuilt with more rigor than before — since whatever was in place clearly wasn’t sufficient protection against this outcome.

Follow the 3-2-1 principle: 3 copies of your data, across 2 different storage locations, with 1 copy kept off-site and separate from your hosting account entirely.

Site TypeFrequencyRetentionNotes
Personal blogDaily7–14 daysAutomated, off-site cloud storage is sufficient
Business websiteDaily, plus before every update30 daysEncrypted, off-site, with periodic restore testing
WooCommerce storeDatabase multiple times daily; files daily30–90 daysRestore-tested monthly given the business impact of data loss
Agency managing multiple sitesDaily per site, fully automated30–90 days per clientCentralized, isolated per client, with documented restore procedures

Frequently Asked Questions

Can a hacked WordPress website be recovered?
Yes, in the vast majority of cases. Recovery is a methodical process — preserve data, find the entry point, clean thoroughly, and patch the vulnerability — not a single action.

Can I fix a hacked WordPress site without losing content?
Yes. Content lives in the database, which is separate from the WordPress core, plugin, and theme files that typically need replacing. The key is preserving and carefully cleaning the database rather than deleting it.

Should I reinstall WordPress after being hacked?
Replacing core files is a normal, recommended part of recovery — but it’s not a complete fix by itself. Plugins, themes, uploads, and the database all need their own review, since a core reinstall doesn’t touch any of them.

How do I know if WordPress malware is still present after cleanup?
Re-scan after cleanup, not just before. Watch for the original warning signs reappearing, check for new unfamiliar files or users, and monitor closely for several weeks — persistence mechanisms like rogue cron jobs can quietly reintroduce malware into an otherwise clean site.

Can malware survive a WordPress reinstall?
Yes, if it exists in the database, in the uploads directory, in a custom plugin/theme, or in server-level configuration — none of which a core reinstall alone addresses.

How do I remove a WordPress backdoor?
Identify it through file integrity checks, checksum verification, and manual review of suspicious files, then remove it entirely and confirm the original vulnerability that allowed it is patched — otherwise a new backdoor can simply be dropped again.

Will a hacked WordPress website lose Google rankings?
It can, particularly if spam content was indexed or a security warning was applied. Genuine cleanup followed by a proper Search Console review gives you the best path back, though there’s no guaranteed timeline.

How long does WordPress malware removal take?
It varies significantly based on how deeply the compromise spread and how quickly it was caught — a contained infection found early can be resolved in hours; a widespread, long-undetected compromise can take considerably longer to fully investigate and clean.

Should I restore a backup after a WordPress hack?
Only a verified-clean backup, and only after you’ve identified and patched the vulnerability that led to the compromise. Restoring a recent backup without checking it, or without fixing the root cause, risks reintroducing the same problem.

What should I do if my WordPress admin account was hacked?
Change the password from a clean device, enable 2FA, revoke all active sessions, check for other rogue accounts the attacker may have created, and review what actions were taken while the account was compromised.

How do I clean malware from the WordPress database?
Back up the database first, then search wp_options, wp_posts, wp_postmeta, and wp_users for injected content using targeted queries — never broad, unverified UPDATE or DELETE statements.

Can a WordPress security plugin remove all malware?
No single tool catches everything. Security plugins are a useful layer for detection and routine scanning, but sophisticated or custom malware can evade signature-based detection — treat plugin scans as one input, not a final verdict.

How do I stop my WordPress website from being hacked again?
Patch the specific vulnerability that was exploited, keep everything updated going forward, enforce 2FA and least privilege, add a real WAF, and monitor continuously rather than only checking in after something looks wrong.

Is it safe to keep using WordPress after being hacked?
Yes — the vast majority of compromises trace back to outdated software, weak credentials, or vulnerable plugins/themes, not a fundamental flaw in WordPress core itself. Addressing those specific causes meaningfully reduces future risk.

Do I need to notify my hosting provider if my site was hacked?
Yes, generally worth doing early — many hosts have security teams with visibility you don’t have, and a compromised site can also affect other accounts on shared infrastructure, which your host needs to know about regardless.

What’s the biggest mistake people make when recovering from a WordPress hack?
Cleaning the visible symptom without finding and patching the actual entry point — which is exactly why so many “cleaned” sites get reinfected within days.

Internal Linking Plan

Article TitleTarget KeywordSearch IntentSuggested Anchor Text
How to Secure WordPress Against Hackerswordpress securityInformational“complete WordPress security guide”
WordPress Malware Removal Guidewordpress malware removalProblem-solving“step-by-step malware removal process”
Best WordPress Security Plugins Comparedbest wordpress security pluginCommercial investigation“comparing WordPress security plugins”
The Complete WordPress Firewall Guidewordpress firewallCommercial investigation“how a WordPress firewall works”
WordPress Security Headers Explainedwordpress security headersDeveloper intent“configuring WordPress security headers”
How to Secure wp-config.phpwp-config.php securityDeveloper intent“hardening wp-config.php”
WordPress Two-Factor Authentication Setupwordpress 2faInformational“setting up 2FA on WordPress”
Stopping WordPress Brute-Force Attackswordpress brute force protectionProblem-solving“blocking brute-force login attempts”
Building a WordPress Backup Strategywordpress backup strategyCommercial investigation“a complete WordPress backup strategy”
WordPress File Permissions Explainedwordpress file permissionsDeveloper intent“correct WordPress file permissions”
WordPress REST API Security Guidewordpress rest api securityDeveloper intent“securing WordPress REST API endpoints”
Preventing SQL Injection in WordPresswordpress sql injection preventionDeveloper intent“preventing SQL injection”
Preventing XSS in WordPresswordpress xss preventionDeveloper intent“cross-site scripting prevention”
Setting Up a Cloudflare WAF for WordPresscloudflare waf wordpressCommercial investigation“configuring a WAF for WordPress”
WooCommerce Security Checklistwoocommerce securityCommercial investigation“WooCommerce-specific security checklist”
How to Detect WordPress Malwaredetect wordpress malwareInformational“detecting WordPress malware early”
WordPress Vulnerability Scanning Guidewordpress vulnerability scannerCommercial investigation“scanning for WordPress vulnerabilities”
WordPress Security Monitoring Toolswordpress security monitoringCommercial investigation“ongoing WordPress security monitoring”
WordPress Plugin Security Best Practiceswordpress plugin securityInformational“evaluating plugin security”
WordPress Theme Security Checklistwordpress theme securityInformational“WordPress theme security checklist”

Visual Content Plan

ConceptSEO FilenameAlt TextPlacement
WordPress hacking attack chainwordpress-hack-attack-chain.webpDiagram of a typical WordPress attack chainEntry-point section
Emergency response timeline (0–24 hours)wordpress-hack-response-timeline.webpTimeline of first response steps after a WordPress hackFirst 30 minutes section
Backup architecture (clean vs infected vs forensic)wordpress-backup-types-diagram.webpDiagram comparing WordPress backup typesBackup section
Malware detection workflowwordpress-malware-detection-workflow.webpWordPress malware detection workflow diagramMalware types section
File vs database infection comparisonwordpress-file-vs-database-infection.webpDiagram comparing file-based and database-based WordPress infectionsDatabase cleaning section
Full recovery process flowchartwordpress-recovery-process-flowchart.webpStep-by-step WordPress hack recovery flowchartClean WordPress safely section
SEO recovery workflowwordpress-seo-recovery-workflow.webpWordPress SEO recovery workflow after a hackSEO recovery section
WooCommerce security recovery diagramwoocommerce-hack-recovery-diagram.webpWooCommerce store hack recovery diagramWooCommerce section
Post-hack hardening checklist infographicwordpress-post-hack-hardening-checklist.webpWordPress hardening checklist after a hackHardening section
Before vs after recovery comparisonwordpress-before-after-recovery.webpBefore and after comparison of a recovered WordPress siteConclusion / near top as a summary visual

SEO Package

SEO Title: How to Fix a Hacked WordPress Website Without Losing Data: Complete Recovery Guide for 2026

Meta Description: A hacked WordPress site can be recovered without losing your content. Follow this complete, step-by-step 2026 guide to clean malware and restore your site safely.

URL Slug: /fix-hacked-wordpress-website-recovery-guide/

Primary Keyword: how to fix a hacked WordPress website

Secondary Keywords: hacked WordPress site, WordPress malware removal, WordPress hacked recovery, remove malware from WordPress, WordPress security cleanup, recover hacked WordPress website, WordPress malware scanner, WordPress website security, WordPress hack recovery, WordPress backdoor removal

Search Intent: Primarily problem-solving/transactional (active incident recovery), with supporting informational intent (warning signs, prevention) and commercial investigation (scanners, hosting, WAF options).

Suggested Schema: Article/TechArticle, FAQPage, HowTo (for the step-by-step recovery workflow), BreadcrumbList.

Editorial note: this guide covers general WordPress recovery principles. Before publishing, verify any references to specific vulnerabilities, CVEs, or 2026 WordPress version numbers against current sources such as WordPress.org, WPScan, NVD, and CISA — no specific incidents, statistics, or CVEs have been invented in this article.

Found this helpful? Share it with your network.

Written by
admin

Security researcher and WordPress specialist contributing in-depth analysis and hardening guides.

Leave a Comment

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