Getting hacked is one of the worst nightmares for a WordPress website owner. A hacked site can lead to data loss, malware infections, Google blacklisting, and security vulnerabilities. If your site is compromised, acting fast is crucial to prevent further damage.
In this step-by-step guide, weβll walk you through how to restore a hacked WordPress website, remove malware, and secure your site from future attacks.
Signs That Your WordPress Website Has Been Hacked
Before restoring your website, confirm whether it has been hacked. Here are some common signs of a hacked WordPress site:
β Unexpected Redirects β Visitors are being sent to malicious websites. β Google Blacklisting Warning β Your website appears with a βThis site may be hackedβ warning in Google search. β Strange Admin Users β New unknown admin accounts appear in your WordPress dashboard. β Injected Spam Content β Your website displays unwanted pop-ups, ads, or spammy links. β Unusual Server Resource Usage β Your site is suddenly consuming high CPU or bandwidth. β Defaced Website β Hackers change your homepage or add offensive content. β Malware Alerts from Hosting Provider β Your hosting company notifies you about malicious activity.
Step-by-Step Guide to Restoring a Hacked WordPress Website
Step 1: Stay Calm & Put Your Website in Maintenance Mode
π Don’t panic! The first thing you should do is temporarily take your site offline to prevent further damage.
π§ How to do it:
- If you can access your WordPress dashboard, install the WP Maintenance Mode plugin.
- If you donβt have access, use cPanel or FTP to display a temporary maintenance page.
π Purpose: This prevents users and search engines from accessing a compromised website.
Step 2: Scan Your Website for Malware
Now, check for malware, infected files, and unauthorized changes.
π Best WordPress Malware Scanners:
- Wordfence Security β Free security scanner & firewall.
- Sucuri SiteCheck β Online malware scanner.
- MalCare β Automated malware removal tool.
π§ How to scan your site:
- Use Wordfence Security β Go to Wordfence β Scan and start a full scan.
- Check your hosting panel β Some hosts like SiteGround, Kinsta, and WP Engine offer built-in malware detection.
- Use Google Safe Browsing β Check if Google has flagged your site by searching:
π Purpose: This helps you identify the source of the hack.
Step 3: Reset All Passwords & Revoke Unauthorized Users
π Immediately change passwords to prevent further unauthorized access.
β Change the following:
- WordPress admin password
- Hosting cPanel password
- FTP/SFTP credentials
- Database password
- Email account passwords (if compromised)
π§ Remove Unknown Users:
- Go to Users β All Users in WordPress.
- Delete unknown admin accounts.
- If you see new administrator accounts that you didnβt create, your site has been compromised.
π Purpose: Prevent hackers from regaining access to your website.
Step 4: Restore Your Website from a Clean Backup
If you have a recent clean backup, restore your site to before the hack.
π How to restore a backup:
- If using UpdraftPlus, go to Settings β UpdraftPlus Backups β Restore.
- If your host offers automatic backups (like Kinsta, Cloudways, or SiteGround), restore from the last known good version.
- For cPanel users, go to File Manager β Restore Backup.
π What if You Donβt Have a Backup?
- Proceed to Step 5 to manually remove malware and fix your site.
Step 5: Manually Remove Malware & Malicious Code
If you canβt restore from a backup, manually clean infected files.
π§ Steps to remove malware manually:
- Access your website files via FTP or cPanel File Manager.
- Check core WordPress files (wp-config.php, .htaccess, index.php) for suspicious code.
- Delete unknown PHP files from /wp-content/themes/ and /wp-content/plugins/.
- Reinstall WordPress core files by uploading fresh versions from WordPress.org.
π Warning: Be careful when deleting filesβremoving critical files may break your site.
Step 6: Reinstall WordPress Core, Themes & Plugins
To ensure no hidden malware remains, reinstall WordPress core files, themes, and plugins.
π§ How to do it:
- Reinstall WordPress Core: Go to Dashboard β Updates β Reinstall WordPress.
- Delete all inactive themes & plugins: Go to Plugins β Installed Plugins and delete unnecessary ones.
- Manually reinstall your theme and plugins: Download fresh copies from the official WordPress repository.
π Purpose: Removes backdoors hackers may have left behind.
Step 7: Secure Your Website & Prevent Future Attacks
Now that your website is clean, protect it from future hacks.
π Essential Security Measures: β Install a security plugin β Use Wordfence or Sucuri to monitor for attacks. β Enable Two-Factor Authentication (2FA) β Prevents unauthorized logins. β Limit Login Attempts β Install Limit Login Attempts Reloaded plugin. β Disable XML-RPC β Prevents brute force attacks (use the Disable XML-RPC plugin). β Move wp-login URL β Change your login URL using WPS Hide Login. β Schedule daily backups β Use UpdraftPlus or Jetpack Backup. β Use a Web Application Firewall (WAF) β Cloudflare or Sucuri for extra protection.
Final Thoughts
Recovering from a WordPress hack can be stressful, but following these step-by-step actions will help you restore your site safely and prevent future attacks.
β Key Takeaways: βοΈ Scan your site for malware & suspicious activity. βοΈ Reset passwords & remove unauthorized users. βοΈ Restore from a clean backup if available. βοΈ Manually remove infected files if no backup exists. βοΈ Reinstall WordPress core, themes, and plugins. βοΈ Implement security best practices to prevent future hacks.
By securing your site properly, you can keep hackers out and maintain a safe WordPress website for the long term! π
