WordPress malware removal is the process of cleaning malicious code, backdoors and unauthorised users from a compromised WordPress site and making it secure again. The most common signs are visitors being redirected to other sites, Google’s “This site may be hacked” warning or a malicious file notice from your hosting provider.
In this guide we explain step by step how to clean an infected WordPress site and how to prevent it from being infected again.
Signs That Your Site Is Infected
- Visitors, especially on mobile or arriving from Google, being redirected to unrelated sites
- Pages you don’t recognise in Google search results (e.g. pharma, gambling or Japanese spam pages)
- A security warning in the browser or in Search Console
- Users you don’t recognise in the admin dashboard
- Unknown PHP files in the root directory or in wp-content/uploads
- An unexplained increase in server resource usage or an abuse notice from your hosting provider
1. Contain the Situation First
- If possible, put the site into maintenance mode or take it offline temporarily.
- Take a full backup of its current state (even though it’s infected); you may need it for investigation.
- Change the hosting panel, FTP/SFTP, database and all WordPress administrator passwords.
2. Do You Have a Clean Backup?
If you have a clean backup from before the attack, restoring it is the fastest solution. After restoring, don’t forget to update the plugin or theme that caused the vulnerability and to change your passwords; otherwise the site will be compromised again shortly.
3. Scan the Files
- Hosting scanner: if cPanel has Imunify360 or a similar scanner, start a full scan.
- Security plugin: use a plugin such as Wordfence to compare core files with the originals and scan for malicious code.
- Manual check: look at recently modified files. If you have SSH access,
find . -name "*.php" -mtime -7lists PHP files changed in the last 7 days. - Suspicious code:
eval(,base64_decode(,gzinflate(and long meaningless strings are common signs. Not every piece of code using these functions is malicious; review carefully.
4. Reinstall WordPress Core
- Back up your wp-config.php file and your wp-content folder.
- Delete the wp-admin and wp-includes folders and replace them with a clean copy of the same version downloaded from WordPress.org.
- Replace the core files in the root directory (index.php, wp-login.php, etc.) with clean copies too.
- Open wp-config.php and check for lines of code you don’t recognise.
5. Clean Plugins and Themes
- Delete unused plugins and themes completely.
- Reinstall the ones you use with clean copies downloaded from official sources.
- If you use nulled (cracked) themes or plugins, remove them; these files are a frequent source of infection.
- There should be no PHP files in wp-content/uploads; review and delete any you find.
6. Check the Database and Users
- Delete administrator accounts you don’t recognise under Users.
- Look for hidden links or scripts injected into post and page content.
- Check that the siteurl and home values in the wp_options table are correct.
- Always take a backup before database operations.
7. Renew the Security Keys
Replace the security keys (salts) in wp-config.php with new values from WordPress’s key generator service. This ends all open sessions and stops the attacker from logging in with stolen session cookies.
8. Remove the Google Warning
Once the site is clean, check the Security issues report in Google Search Console and submit a Request review. If spam pages were indexed, those URLs should return 404 or 410; you can speed up the process with the removals tool.
Preventing Reinfection
- Update WordPress, themes and plugins regularly.
- Install a WordPress security plugin and turn on two-factor authentication.
- Use strong, unique passwords; store them in a password manager, not in the browser.
- Take automatic backups stored off the server.
- Set file permissions correctly (usually 644 for files and 755 for folders).
- Choose hosting that offers server-level malware scanning.
Frequently Asked Questions
Does a security plugin remove the malware completely?
It can find and clean known malicious code, but it may not always catch hidden backdoors. Replacing core and plugins with clean copies is more reliable.
The site was reinfected after cleaning. Why?
Usually a backdoor was left behind or the plugin that caused the vulnerability wasn’t updated. Make sure you changed all passwords and security keys.
Why did my hosting provider suspend the site?
Because malicious files can affect other sites and the server’s reputation, hosting providers may temporarily restrict infected accounts. After cleaning, you can let the support team know and ask for the account to be reopened.
Categories
-
CentOS 7 guides
-
cPanel 20 guides
-
CyberPanel 18 guides
-
Operating Systems 81 guides
-
Juniper Networks 18 guides
-
Control Panels 50 guides
-
Linux 17 guides
-
MySQL 29 guides
-
Network 94 guides
-
Plesk Panel 12 guides
-
Virtual Servers 273 guides
-
SEO 3 guides
-
Cyber Security 8 guides
-
Technology 162 guides
-
VMware 36 guides
-
WordPress 20 guides
-
Artificial Intelligence 22 guides