How to Remove Malware From WordPress: A Practical Walkthrough

If you’ve confirmed malware on your WordPress site, finding one suspicious file and deleting it may feel like the obvious fix. But malware can hide in more than one place, and a site can appear clean while a backdoor or compromised account quietly restores it.
A thorough WordPress malware removal process checks three areas: website files, the database, and access accounts, including users, active sessions, and security keys. This guide walks through the work in a careful order. Some steps require hosting or command-line experience; if you’re unsure, avoid making changes you can’t easily reverse.
1. Make a safe copy before changing anything
Record what you’ve observed: warnings, redirects, unfamiliar users, modified pages, and when the problem began. Save screenshots and, if available, ask your hosting provider to preserve relevant logs.
Next, make a full copy of both the website files and the database. Store it somewhere separate from the live site. Treat this as a reference copy, not a clean backup to restore: it may contain the infection, but it can help you recover content or investigate what changed.
If possible, put the site into maintenance mode while you work. Ask your host whether the account or other sites on the same hosting plan may also be affected.

2. Identify what’s infected
A scanner can help point to suspicious files, scripts, or injected content. Keep a record of its findings, but don’t assume every alert is a confirmed infection, or that a clean scan proves the site is safe. Scanners may miss backdoors, database injections, and malicious code that activates only under certain conditions.
Review the site through your hosting file manager or SFTP, and compare the results with clean copies of WordPress, your theme, and your plugins. Check:
- WordPress core files, especially files that have changed unexpectedly
- Active and inactive themes and plugins
wp-content/uploadsfor files that don’t belong there, especially executable files such as PHPwp-content/mu-pluginsfor must-use plugins you didn’t add or don’t recognize- Site configuration and server rules, including
wp-config.phpand.htaccess - Scheduled tasks or cron jobs that could recreate malicious files
Must-use plugins load automatically and may not appear in the regular plugins list. Similarly, a strange-looking file or unfamiliar code pattern is a clue to investigate, not proof by itself. Compare it with the official or original clean version before removing it.

3. Replace compromised files with clean copies
For WordPress core, obtain clean files from the official WordPress download page or use a qualified administrator to reinstall the core files. Don’t overwrite or replace files blindly: preserve your site-specific configuration and content, and make sure the replacement process doesn’t leave unknown extra files behind.
For themes and plugins, reinstall clean copies from the WordPress.org directory or the original trusted developer. If a plugin or theme is abandoned, no longer maintained, or came from an untrusted source, remove it and find a suitable replacement. Inactive plugins can still contain files on the server, so review those too.
Don’t delete everything that looks unusual. A legitimate customization may look unfamiliar, and careless removal can break your site. If you can’t tell whether a file is required or malicious, quarantine it outside the public website directory or ask your host or a WordPress security professional to review it.
4. Check the database for injections and hidden users
Malicious changes may be stored in the database, not in a file. Before editing it, make a fresh database export. Then review the areas that commonly contain website content and settings:
- Users and roles: Look for unfamiliar administrator accounts. Also check that known users have the roles you expect. The users table may use a custom prefix instead of
wp_. - Site options: Confirm the site address and home address are correct. Review unfamiliar options, unexpected remote URLs, or suspicious code.
- Pages, posts, and metadata: Look for injected scripts, spam links, or content that you didn’t add.
- Widgets and other stored settings: Check for malicious snippets or unwanted redirects.
Remove only the malicious content you’ve identified. Broad find-and-replace operations or deleting database rows without understanding them can damage pages or settings. If an unexpected admin account appears, preserve the information needed for investigation, then remove it safely and check for any other accounts you don’t recognize.
5. Remove backdoors and investigate how the attacker got in
Removing visible malware isn’t enough if a backdoor remains. Recheck suspicious files, must-use plugins, server rules, and scheduled tasks for code that could restore the infection or create a new administrator. Ask your hosting provider to review server-level scheduled jobs and logs if you don’t have access to them.
Then investigate the likely entry point. Common possibilities include an outdated or vulnerable plugin or theme, a compromised hosting or FTP account, a weak or reused password, or an infected computer used to access the site. The evidence may not make the cause obvious. Review available logs and talk to your host rather than guessing.
Fix the cause before considering the cleanup finished. That may mean updating vulnerable software, removing an unsafe plugin, changing hosting access, or scanning the devices used to manage the site. WordPress’s hardening guidance covers updates, trusted software sources, passwords, backups, and access controls.
6. Rotate credentials and invalidate old sessions
Once the malicious code is removed, change the passwords for WordPress accounts, especially administrators, and for hosting, SFTP/FTP, and database access. Use unique passwords and update the database password wherever it is stored in your site configuration. If an account or device may be compromised, secure that access route too.
Regenerate the WordPress security keys and salts in wp-config.php. The official WordPress secret-key generator provides replacement values. Updating these keys invalidates existing login cookies, so users will need to sign in again. Review application passwords and other access tokens as well; changing a user’s regular password may not revoke every separate credential.

7. Verify the cleanup from more than one angle
After cleaning, check the site as an administrator and as a visitor. Use a fresh browser session, and test pages, forms, logins, and checkout if your site has one. Look for redirects, unexpected pop-ups, broken content, and changes to users or files.
Run a new site scan and, where possible, compare files with clean WordPress, theme, and plugin versions. Ask your hosting provider to check server logs and scheduled tasks. Recheck the site after a little time: if suspicious files, accounts, or redirects return, something may have been missed.
If the site was flagged by Google, review its Security Issues report in Search Console and follow Google’s process after you’ve addressed the issue. A scan result by itself is not the same as confirmation that every layer is clean.
When a scanner isn’t enough
A scanner is a useful starting point, not a complete cleanup plan. It may not find malicious database content, hidden administrator accounts, server-level changes, or a backdoor that uses ordinary-looking code. It can also flag legitimate custom code for review.
Get help if you can’t safely compare files or inspect the database, if your host has suspended the site, if malware keeps returning, or if your site handles customer accounts or payments. A professional cleanup should look beyond the alert: files, database, access accounts, backdoors, and the likely entry point all need attention. The Hack Remover helps small businesses clean compromised websites, harden them, and get them back online. If you’re deciding who should handle the work, see our DIY vs professional cleanup comparison.
What not to do
- Don’t mass-delete suspicious files. You could break the site and still leave the real backdoor behind.
- Don’t restore an infected backup and assume the problem is solved. A backup is useful only if you have good reason to trust it.
- Don’t leave old or unknown administrator accounts in place.
- Don’t skip the entry point. If the vulnerability or compromised access remains, the site may be infected again.
WordPress malware removal is methodical work, not a single scan or file deletion. Preserve a copy, check files and database, review every way into the site, fix the cause, and verify the result. When a step feels uncertain, pause and get help before making changes that could take your website offline.