How to Clean a Hacked WordPress Site
WordPress powers over 43% of the web, its popularity makes it a prime target for hackers. This guide provides a clear, step-by-step process to clean your hacked site, restore its integrity, and implement robust security measures to prevent it from ever happening again.
Step 1: Containment and Assessment
The moment you suspect a hack, your first priority is to contain the damage. Acting quickly but methodically can prevent the infection from spreading further or causing more harm.
- Put Your Site in Maintenance Mode: Use a plugin like WP Maintenance Mode or add a simple
.maintenancefile to your site's root directory. This prevents visitors from accessing the potentially malicious site and lets you work behind the scenes. - Contact Your Hosting Provider: Your host should be your first call. A quality host will have a dedicated security team that can help you identify the scope of the breach. This is where the difference between cheap, shared hosting and premium managed hosting becomes stark. A provider like SiteGround or WP Engine often includes proactive monitoring and expert support that can be invaluable in a crisis. In contrast, some budget hosts may offer limited assistance, leaving you to handle the cleanup alone.
- Change Critical Passwords Immediately: Before you do anything else, change your passwords. Start with your WordPress admin accounts, then move to your hosting control panel (cPanel/Plesk), FTP/SFTP accounts, and your database password. Assume every credential has been compromised.

Step 2: Identify the Hack and Find the Malware
To clean the site, you first need to know what you're dealing with. Hacks can range from simple spam injections to complex backdoors that give attackers persistent access.
Common Signs of a Hack:
- Your site is redirecting to spammy or malicious websites.
- Strange pop-ups or ads appear on your pages.
- Google Chrome or other browsers show a security warning when visiting your site.
- Your hosting provider suspends your account for sending spam emails or launching DDoS attacks.
- You see new, unknown user accounts with administrator privileges in your WordPress dashboard.
- Your site's files have been modified or new, suspicious files have appeared on your server.
- A sudden, unexplained drop in traffic or a warning in Google Search Console's 'Security Issues' tab.
Using Scanning Tools
Automated tools are the fastest way to pinpoint malicious code. Install a reputable security plugin on a clean WordPress installation and connect it to your site for scanning.
- Wordfence Security: One of the most popular WordPress security plugins. Its scanner compares your core files, themes, and plugins with the versions in the official WordPress repository, flagging any modifications, and also scans for known malware signatures.
- Sucuri Security: Offers a powerful remote scanner (SiteCheck) that can identify malware, blacklist status, and website errors from the outside. The installed plugin provides deeper server-side scanning.
- MalCare: This plugin is known for its deep scanning capabilities that don't overload your server. It can identify and often remove malware with a single click.
Run a full scan and carefully review the results. The scanner will list infected files, malicious code injections, and other security vulnerabilities. Do not delete files randomly; some may be legitimate files that have been infected, not malicious files themselves.
Step 3: The Deep Clean - Removing Malicious Code
With the scan report in hand, it's time to perform surgery. You have two primary options: professional help or a manual cleanup.
Option A: Hire a Professional (Recommended for Most)
If you're not comfortable editing code or navigating server files, hiring a professional service like Sucuri or Wordfence's site cleaning service is the safest and most effective option. It saves time and ensures the job is done thoroughly.

Option B: The Manual Cleanup
If you have technical expertise, you can proceed manually. Warning: Before you begin, create a full backup of the hacked site. This may seem counterintuitive, but this backup is for forensic purposes and serves as a safety net if you make a mistake during the cleanup.
- Replace WordPress Core Files: Download a fresh copy of WordPress from WordPress.org. Unzip the file and delete the
wp-contentfolder and thewp-config-sample.phpfile. Then, upload the remaining files and folders to your server via FTP/SFTP, overwriting the existing core files. This replaces any compromised core files with clean ones. - Clean Your
wp-config.phpand.htaccessFiles: These are common targets. Carefully inspect yourwp-config.phpfile for any strange or malicious-looking code. Compare it to thewp-config-sample.phpfile from your fresh WordPress download. For the.htaccessfile, you can often delete it and have WordPress regenerate a clean one by going to Settings > Permalinks in your dashboard and clicking 'Save Changes'. - Inspect Your
wp-contentFolder: This is where most infections hide.- Plugins and Themes: Delete and reinstall all your plugins and themes from official sources. Do not just overwrite them; delete the old folders completely first. This ensures any backdoor files hidden within those directories are removed.
- Uploads Directory: Manually scan your
wp-content/uploadsdirectory. It should only contain media files (images, videos, PDFs). If you find any PHP, JS, or other executable files, delete them immediately.
- Clean Your Database: Hackers often inject spammy links or create fake admin users in the database. Use a tool like phpMyAdmin to inspect your
wp_userstable and delete any unauthorized admin accounts. Check yourwp_postsandwp_optionstables for spammy content or malicious scripts.
Step 4: Hardening Your Site for the Future
Cleaning your site is only half the battle. Now you must secure it to prevent a re-infection. This starts with your hosting foundation.
Your Host is Your First Line of Defense
The security of your website is directly tied to the quality of your hosting. While very affordable hosting is tempting for a new venture, a security breach can cost far more in the long run. When choosing the best hosting for a small business, security should be a top priority alongside site speed.
- Shared Hosting: The cheapest option, but you share server resources and an IP address with hundreds of other sites. A vulnerability on another site could potentially impact yours.
- VPS Hosting: Offers more control and isolation than shared hosting, but you are often responsible for your own security configurations.
- Managed WordPress Hosting: This is often the best choice for security-conscious business owners. Providers like Kinsta, WP Engine, and a well-configured SiteGround plan offer a platform optimized for WordPress. They typically include server-level firewalls, free SSL, daily automated backups, proactive malware scanning, and expert support. Investing in fast website hosting that is also secure is one of the smartest decisions you can make.
Essential WordPress Security Best Practices:
- Use Strong, Unique Passwords: For everything—admin, FTP, database. Use a password manager.
- Enable Two-Factor Authentication (2FA): This adds a critical layer of security to your login page.
- Keep Everything Updated: Your WordPress core, themes, and plugins must always be on the latest version. Use auto-updates where possible.
- Install a Web Application Firewall (WAF): A WAF like Sucuri's or Cloudflare's can block malicious traffic before it even reaches your server.
- Limit Login Attempts: Prevent brute-force attacks by limiting the number of failed login attempts.
- Regularly Backup Your Site: Schedule automated, off-site backups. If the worst happens, a clean backup is your fastest path to recovery.
Step 5: Post-Hack Final Actions
Once your site is clean and secure, you have a few final tasks.
- Request a Review from Google: If your site was blacklisted, use the 'Security Issues' report in Google Search Console to request a review. Once Google verifies your site is clean, they will remove the warnings.
- Inform Your Users: If there's a chance user data was compromised, you have an ethical (and often legal) obligation to inform them.
Take Control of Your Website's Security
A hacked website is a stressful, damaging experience, but it's also a powerful lesson in the importance of proactive security. By following these steps, you can not only recover from an attack but also build a much stronger, more resilient online presence. Your choice of hosting, your password discipline, and your update routines are the pillars of a secure website.
Have you ever dealt with a hacked site? Share your experience or your favorite security tip in the comments below! Save this post for your emergency toolkit and share it with a fellow website owner who needs it.
