Finding out your WordPress site has been hacked is one of the worst feelings a business owner can experience. Your website — your digital shopfront, your credibility, your marketing engine — has been compromised.
Take a breath. This guide will walk you through exactly what to do, whether you’re handling it yourself or bringing in professionals.
How to Know If Your Site Is Infected
Sometimes malware is obvious. Other times, it’s deliberately hidden. Here are the common signs:
Visible Signs
- Defaced homepage — Content replaced with hacker messages
- Spam content — Pharmaceutical ads, casino links, or adult content appearing on your pages
- Redirects — Visitors sent to suspicious websites
- Pop-ups — Aggressive advertising that you didn’t add
- Slow loading — Site becomes unusually slow
Hidden Signs
- Google warnings — “This site may be hacked” in search results
- Browser warnings — Chrome or Firefox blocking access with red warning pages
- Hosting suspension — Your host disables your site for security reasons
- Unknown admin users — User accounts you didn’t create
- Modified files — Core WordPress files with recent change dates
- Strange server activity — Unusual bandwidth usage or processing load
Technical Indicators
- Unknown files in your WordPress installation
- Obfuscated code (long strings of random characters)
- Base64-encoded content in theme or plugin files
- Modified .htaccess file with strange redirects
- New scheduled tasks (cron jobs) you didn’t create
Step 1: Don’t Panic, But Act Fast
Malware can spread and cause more damage the longer it remains. But rushing into cleanup without a plan often makes things worse.
Immediately:
- Don’t delete anything yet
- Document what you’re seeing (screenshots)
- Note when you first noticed the problem
- Check if you have recent clean backups
Step 2: Put Your Site in Maintenance Mode
You don’t want visitors seeing malware or Google continuing to crawl infected pages.
Create a simple maintenance page or use a maintenance mode plugin. If your site is actively redirecting visitors to malicious sites, consider taking it offline entirely by renaming the index.php file temporarily.
Step 3: Reset All Passwords
Before you even start cleaning, assume all credentials are compromised:
- WordPress admin passwords — All user accounts, not just yours
- Database password — In your wp-config.php file
- FTP/SFTP passwords — File access credentials
- Hosting control panel — cPanel, Plesk, or similar
- Associated email accounts — Especially if used for password resets
Use strong, unique passwords for each. A password manager like 1Password or Bitwarden is essential.
Step 4: Identify the Infection
Before you can clean malware, you need to find it. There are several approaches:
Use a Security Scanner
Wordfence (free version):
- Install and activate Wordfence
- Go to Wordfence > Scan
- Run a full scan
- Review flagged files
Sucuri SiteCheck (free):
- Visit sitecheck.sucuri.net
- Enter your website URL
- Review the report for malware indicators
Manual File Inspection
For those comfortable with file access:
- Connect via SFTP (not regular FTP)
- Look for recently modified files (last 30 days)
- Check common infection points:
- wp-config.php
- .htaccess
- index.php in root and wp-includes
- Files in wp-content/uploads (PHP files shouldn’t be here)
- Unknown files in theme folders
Compare Against Clean WordPress
Download a fresh copy of your WordPress version from wordpress.org and compare core files. Any differences in wp-includes or wp-admin folders indicate tampering.
Step 5: Clean the Infection
Option A: Restore from Clean Backup
If you have a backup from before the infection:
- Confirm the backup is clean by scanning it
- Restore files and database
- Update all passwords (malware might have captured them)
- Update WordPress, themes, and plugins immediately
Warning: If you don’t know when the infection started, your backup might also be compromised.
Option B: Manual Cleanup
If you don’t have clean backups, you’ll need to clean manually:
Replace WordPress Core:
- Download fresh WordPress from wordpress.org
- Delete wp-includes and wp-admin folders entirely
- Upload the fresh versions
- Compare and replace individual files in the root directory
Clean wp-content:
- Replace plugins with fresh downloads from wordpress.org
- Replace themes with fresh downloads
- Check uploads folder for PHP files (delete any you find)
- Review wp-content for unknown folders
Clean the Database:
- Check for unknown admin users (delete them)
- Look for spam content in posts and comments
- Review wp_options for suspicious entries
- Check for unknown scheduled events
Review wp-config.php:
- Compare against a fresh wp-config-sample.php
- Remove any code that doesn’t belong
- Generate new security salts at api.wordpress.org/secret-key
Step 6: Identify and Close the Entry Point
Cleaning malware without fixing how it got in means you’ll be reinfected. Common entry points:
Outdated Software
Check if any themes or plugins were outdated when the hack occurred. Update everything now.
Weak Passwords
If any admin account had a weak password, that’s likely how attackers got in.
Vulnerable Plugins
Some plugins have known vulnerabilities. Check if any of your plugins appear on vulnerability databases like WPScan.
Compromised Computer
If your local computer has malware, it can capture your FTP or WordPress credentials. Run a full antivirus scan.
Insecure Hosting
Shared hosting with poor isolation can allow one compromised site to affect others. Consider managed WordPress hosting with proper security isolation.
Step 7: Implement Protection
Once clean, prevent future infections:
Essential Security Measures
- Keep everything updated — WordPress core, themes, and plugins
- Use strong passwords — For everyone with access
- Enable two-factor authentication — For all admin accounts
- Install a security plugin/firewall — Wordfence, Sucuri, or Patchstack
- Regular backups — Daily at minimum, stored off-site
Advanced Protection
- Web Application Firewall (WAF) — Blocks malicious requests
- File integrity monitoring — Alerts you to unexpected changes
- Login attempt limiting — Stops brute force attacks
- Security headers — Prevent clickjacking and XSS attacks
Step 8: Request Review from Google
If Google flagged your site as hacked:
- Log into Google Search Console
- Go to Security & Manual Actions > Security Issues
- Review the detected issues
- Once clean, click “Request Review”
- Wait for Google to re-crawl (can take days to weeks)
When to Call Professionals
Consider professional malware removal if:
- The infection is complex or keeps returning
- You’re not comfortable with file-level access
- Your site handles sensitive customer data
- You can’t afford extended downtime
- You’re not sure the infection is fully removed
Professional services typically cost €200-500 for thorough cleanup and security hardening.
What SparkHost Does Differently
Our WordPress security services don’t wait for infections to happen. On our Managed plans:
- Proactive monitoring — We detect suspicious changes before they become problems
- Automatic updates — Core, themes, and plugins kept current
- Patchstack protection — Virtual patching for known vulnerabilities
- Daily backups — Clean restore points always available
- Hack recovery — If something does get through, cleanup is included
Prevention is always cheaper than cure.
Lessons Learned
Most WordPress infections are preventable. They happen because of:
- Outdated software left unpatched
- Weak or reused passwords
- Pirated (“nulled”) themes or plugins
- Poor hosting security
- No monitoring or early detection
Don’t let this happen again. Invest in proper WordPress maintenance now, or budget for cleanup later.
Take Action Today
If your site is currently infected:
- Follow this guide step by step
- Consider professional help if needed
- Document everything for future reference
If your site is currently clean:
- Run a security scan anyway
- Verify your backup system is working
- Enable two-factor authentication
- Review your security measures
The best time to fix your security was before the hack. The second best time is right now. For a comprehensive overview of all security measures, see our WordPress security audit checklist.