To clean hacked WordPress websites and secure them from future malware attacks, start by identifying the infection, backing up your site, removing malicious code, restoring clean files, and hardening security with updates, strong passwords, and security plugins.
A compromised WordPress site can wreak havoc on your traffic, SEO, and reputation. Symptoms often include unexpected redirects to spam sites, search warnings like “This site may be hacked,” or strange content (even foreign text like Japanese) appearing on your pages. In these cases, immediate cleanup is needed. As a WordPress security specialist, I follow a systematic process to clean a hacked WordPress site and secure it against future malware.
We begin by backing up and isolating the site, then scan for malware, remove all malicious code, restore clean files, and finally harden the site against reinfection. For example, security guides stress making a full backup of your files and database before starting malware removal. With a backup in hand and the site in maintenance mode, I proceed to identify and eliminate the infection step by step.

Signs of a Hacked WordPress Site
Detecting a hack early is crucial. Common warning signs include:
- Malicious redirects: Visitors (or even you) may be sent to spammy or unrelated sites. Attackers often inject hidden redirects, so if your site suddenly jumps to a spam page, it’s a clear sign of compromise.
- Search engine warnings: Search engines like Google or Bing might show a warning message, such as “This site may be hacked,” or even block your site completely from search results. If you search your site name and see a red caution, malware is likely present.
- Locked-out admin access: You might find unknown administrator accounts in your dashboard or even lose login access yourself. Unknown “rogue” users or admins with suspicious usernames often appear after a hack.
- Strange content or pop-ups: Hackers may insert spammy posts, adverts or foreign-language text into pages. For example, Japanese or Chinese text might show up on your site or in search results.
If any of the above occur — especially unexpected redirects or search blacklist warnings — treat your site as compromised and proceed with cleanup. (WordPress is widely targeted, and “can be hacked anytime,” so vigilance is essential.)
Step-by-Step Malware Cleanup for WordPress
1. Backup and Quarantine the Site:
Right away, create a full backup of your entire WordPress website, including all files and the database, to keep your data safe before starting any cleanup.
2. Use FTP/SFTP:
Use your web hosting control panel or a backup plugin such as UpdraftPlus to save a complete copy of your entire website. Storing this backup off-server ensures you have a clean copy if needed. Next, enable maintenance mode (or otherwise take the site offline) so no new data is added during cleanup. Also, change all passwords at this stage — WordPress admin, FTP/SSH, database, and hosting accounts — and enforce strong passwords (and 2FA). This prevents the attacker from reusing stolen credentials.
3. Scan for Malware and Identify Infections:
Run a thorough malware scan using security tools such as Wordfence, Sucuri SiteCheck, or other scanners. These will flag infected files or known malware signatures. On the server, you can also search manually for common malware patterns. For example, use SSH or a file manager to grep for suspicious code (e.g., grep -R “base64”) to find encoded payloads. Pay special attention to recently modified files. Scanners or manual inspection will reveal hidden code (like eval, base64_decode, or obfuscated JavaScript) and rogue files.

4. Remove Malicious Code and Files:
Delete every infected plugin or theme, remove them from the wp-content/plugins/ and wp-content/themes/ folders, and reinstall clean copies from official sources.
Stay away from using “nulled” or pirated plugins from unofficial sources, as they often carry hidden backdoors that can compromise your website’s security. Then, carefully clean the code in any infected files.
Open suspect PHP files and remove snippets containing obfuscation (e.g., long Base64 strings, unusual eval() calls, or hidden iframes). If a plugin/theme file is compromised, replace it entirely with a fresh original copy.
Also, inspect the root .htaccess files in each directory: malware often injects malicious redirect rules into .htaccess. By using SSH access, you can run specific commands to find and remove all suspicious or unwanted .htaccess files from your website (for example, find . -name “.htaccess” -exec rm -f {} \;), then regenerate the correct one by resaving permalinks in WordPress. Finally, remove any injected code in wp-config.php or other core config files.

5. Restore WordPress Core and Clean the Database:
Replace all WordPress core files (everything except wp-content and wp-config.php) with fresh copies from wordpress.org. This makes sure that none of the core WordPress files have been altered or damaged by hackers. Also, ensure your active theme and plugins are up-to-date and reinstalled if necessary.
Next, clean the database. Check the database tables, particularly wp_posts, wp_options, and wp_users, to find and remove any spam content or suspicious admin accounts. You may use SQL queries or WP-CLI. For example, a query can strip malicious <script> tags from post content. Delete any spam posts/pages that the hacker created. If many rows are infected, exporting the DB and using a text editor to search-and-destroy malware strings can help. The goal is to remove all injected links or scripts from your content and settings.

6. Secure and Harden the Site:
With the site clean, implement security best practices to prevent re-infection. First, update everything: WordPress core, plugins, and themes should be upgraded to the latest versions (patched against known exploits).
Remove any plugins or themes you no longer use (each extra component is a potential vulnerability). Reinforce access security: recreate a new admin user and delete any suspicious users. Enforce strong passwords and enable two-factor authentication on logins. Configure your file permissions correctly (e.g., folders 755, files 644) so that PHP scripts can’t be written without authorization.
Consider adding a firewall or security plugin (Wordfence, Sucuri, or iThemes Security) to monitor and block attacks. If you use Cloudflare or another CDN, enable its Web Application Firewall to filter malicious traffic at the DNS level.
Finally, once cleaned, go to Google Search Console (or Bing Webmaster Tools) and request a review. Google typically re-scans cleaned sites within a few days and removes the “hacked site” warning, restoring your search rankings.
Preventing Future Malware Attacks
After cleanup, set up ongoing security measures. Perform regular backups and periodic scans (many security plugins can auto-scan weekly). Make sure to regularly update your WordPress core, themes, and plugins to the latest versions to protect your website from security threats. Use strong, unique passwords for all accounts and update them regularly to enhance security.
Remove any unused plugins or themes as soon as they are no longer needed. Limit login attempts and consider restricting wp-admin access by IP. Following these security best practices is essential – for example, Sucuri’s advice includes using a web application firewall, keeping all software patched, enforcing strong passwords and 2FA, and limiting login attempts.
By staying vigilant and implementing layered security (firewall + hardening + monitoring), you greatly reduce the risk of a repeat infection.
Need a Hacked Site Fixed?
Cleaning a hacked WordPress site can be time-consuming and tricky for non-experts. If your site has been compromised or you notice malware symptoms, don’t panic – professional help is available. I offer full WordPress malware removal and hardening services to restore your site’s integrity quickly. Contact me for cleanup and we will work together to recover your site, remove any blacklist warnings, and implement a security plan to protect it from future attacks.
Ready to get your site back? Reach out today to schedule a cleanup and security audit.