Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared Managed Cloud India
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Best lists Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Security · Guide

How to Remove Malware From WordPress

Short answer

To remove malware from WordPress, scan the site with a security plugin, then replace infected core, theme and plugin files with fresh copies from official sources. Clean injected code from the database, delete rogue admin users and backdoors, and rescan until no threats remain. Change every password and secret key only after the site is clean.

Key takeaways

  • A remote scan alone cannot prove a site is clean because it cannot see server files or the database.
  • Replace the wp-admin and wp-includes folders with fresh copies of the same WordPress version you run.
  • Wordfence sends new malware signatures to free users 30 days after Premium users get them, as of November 2026.
  • Check wp_options and wp_posts in the database for injected links, spam posts and strange code.
  • A backdoor left behind lets an attacker return, so removal must cover files, the database and user accounts.
  • Request a review in Search Console only after every flagged page is fixed across the whole site.

What is WordPress malware and how do you know your site has it?

Malware is code added to your site without your permission, and you spot it through warnings, strange behaviour or scan results.

WordPress.org lists clear signs in its FAQ on hacked sites: a blacklist warning, a disabled site, a malware flag, antivirus warnings from visitors, new users you did not create and visible changes. WordPress.org FAQ: My site was hacked

Common signs to record before you change anything are:

  • Browser warnings such as “Deceptive site ahead” or “The site ahead contains malware”
  • Search results that show spam words, drug names or links you did not add
  • Pages that redirect visitors to sites you do not know
  • New administrator accounts, posts or links you did not create
  • A sudden drop in traffic or a message from your host about malware

What do you need before you start removing malware?

You need a full copy of the infected site, access to files and the database, and a note of what you found.

WordPress.org advises one more snapshot of the site before cleaning, even though it is infected. That copy is your safety net if a cleanup step breaks the site, and it keeps a record of what the attacker changed. WordPress.org FAQ: My site was hacked

Gather these items first, and keep the infected copy clearly labelled so nobody restores it by mistake:

  • A full backup of files and the database, stored off the server
  • SFTP or SSH access, plus hosting control panel access
  • Database access through phpMyAdmin or a similar tool
  • Your current WordPress version, found in wp-includes/version.php or Dashboard, then Updates
  • A note of when you first saw the problem and what changed just before it

If you have a clean backup from before the hack, read our guide on how to back up WordPress first so you know what a good copy looks like.

Sucuri notes that comparing the infected site with a known clean backup is the best way to spot changed files. A restore from that backup can be the fastest route back, but only if you then close the hole the attacker used. Sucuri: How to clean a hacked WordPress site

How do you scan a WordPress site for malware?

Run a remote scan and a server-side scan, because each one sees a different part of the site.

Start with a remote scan. Sucuri SiteCheck is a free remote scanner that checks a URL for known malware, viruses, blacklist status, website errors, out-of-date software and malicious code. Enter your domain and read the report it returns. Sucuri SiteCheck

Sucuri warns that SiteCheck only sees what is visible in the browser, so it will not detect anything on the server side. A clean remote result does not prove the site is clean.

Then run a server-side scan with a security plugin. Wordfence says its scan examines all files on a WordPress site for malicious code, backdoors and shells, and also checks for known malicious URLs and known patterns of infection. Open Wordfence, then Scan, and click “Start New Scan”. Wordfence help: Scan

Scan methodWhat it checksWhat it cannot see
Sucuri SiteCheckPublic pages, malware, blacklist statusServer files and the database
Wordfence scanSite files, backdoors, shells, bad URLsNew malware with no signature yet
MalCare scanFiles, database tables, scheduled tasksLittle, if the scan runs fully
WP-CLI checksumsCore files against WordPress.org checksumsPlugins, themes, uploads and the database

Wordfence also warns that free users receive new malware signatures 30 days after Premium users, as of November 2026. A very new infection may therefore go undetected on the free version, so pair the scan with the manual checks in the next section.

MalCare says its scanner checks every file, database table and scheduled task, and points to the exact file and line, or table and row. Its one-click cleanup removes only the malicious code and scans again to confirm the site is clean. MalCare: How to remove malware from WordPress

How do you find infected files by hand?

Compare your files with known clean copies and look for files changed at a strange time.

Sucuri advises checking core file integrity first, because most core files should never change between releases. Download a fresh copy of the same WordPress version and compare it with the files on your server. Sucuri: How to clean a hacked WordPress site

If you have SSH access, WP-CLI can do this check for you. Its wp core verify-checksums command downloads MD5 checksums for your version from WordPress.org and compares them with your installed files, without loading WordPress. A clean result reads “Success: WordPress installation verifies against checksums.” WP-CLI: wp core verify-checksums

Look for recently changed files next. Sucuri shows two SSH commands: ls -1tlah | head -10 lists the 10 most recently changed files, and find . -type f -mtime -90 lists files changed in the last 90 days. Sucuri: How to clean a hacked WordPress site

Check these places in particular:

  • wp-content/uploads for PHP files, since this folder should hold media only
  • wp-content/plugins and wp-content/themes for folders you do not recognise
  • index.php, header.php, footer.php and functions.php in your theme, which WordPress.org names as common targets
  • .htaccess in the site root, which is often edited to add redirects
  • Files with scrambled or encoded code, such as long strings of base64 text

MalCare makes the same point about uploads: if you see PHP files in the uploads folder, delete them, since that folder is not meant to hold them. MalCare: How to remove malware from WordPress

How do you remove malware from WordPress files?

Replace infected files with fresh copies from official sources instead of editing the malicious code out by hand.

Sucuri says to download a fresh WordPress copy from the official site and replace each compromised core file with a clean copy. Do not overwrite wp-config.php or the wp-content folder in this step. Sucuri: How to clean a hacked WordPress site

Follow these steps in order:

  1. Note your WordPress version from wp-includes/version.php
  2. Download that exact version from WordPress.org
  3. Delete the old wp-admin and wp-includes folders through SFTP or your host file manager
  4. Upload the fresh wp-admin and wp-includes folders from the download
  5. Replace the root files that came with WordPress, except wp-config.php
  6. Check .htaccess and restore the default WordPress rules if it holds redirects you did not add

WordPress.org warns that you must reinstall the same version your site uses, since an older or newer one can break the site. It also warns against the dashboard reinstall button, because installers often only overwrite existing files while hacks often add new files. WordPress.org FAQ: My site was hacked

How do you clean themes and plugins?

Delete any plugin or theme you do not recognise, then reinstall the rest from official sources.

Sucuri advises downloading a clean plugin or theme copy from a working backup or the official WordPress site, then replacing the folder inside wp-content/plugins or wp-content/themes with the clean copy. Test the site after each change. Sucuri: How to clean a hacked WordPress site

In the dashboard, go to Plugins, then Installed Plugins, deactivate and delete the affected plugin, then install a fresh copy. Do the same for themes under Appearance, then Themes.

Never reinstall a plugin or theme from a free copy found on another site. Our guide on whether nulled WordPress plugins are safe explains why those copies often carry hidden malware.

How do you clean malware from the WordPress database?

Search the database for spam links, strange code and posts you did not write, then remove only the injected content.

Sucuri says to connect to the database with a tool such as phpMyAdmin or Adminer. Back up the database first, then search for spammy keywords and malicious links. Sucuri: How to clean a hacked WordPress site

Check these tables first:

  • wp_options, especially the siteurl and home rows and any option holding encoded text or a strange link
  • wp_posts for spam posts, hidden pages and injected links in post content
  • wp_users and wp_usermeta for accounts and roles you did not create
  • wp_comments for spam comments that hold links to other sites

Sucuri lists common malicious PHP functions to look for, including eval, base64_decode, gzinflate, preg_replace and str_replace. These functions also appear in normal plugins, so test every change. Sucuri: How to clean a hacked WordPress site

MalCare gives the same short list of tables to check, naming wp_options and wp_posts in particular. Open the row that holds the suspicious content, delete only that content, then test the site to make sure it still works. MalCare: How to remove malware from WordPress

How do you find and remove backdoors and rogue admin users?

A backdoor is a hidden way back in, so look for it in files, scheduled tasks and user accounts at the same time.

Sucuri says hackers always leave a way back in, and it often finds several backdoors of different types in one site. They hide in files named like core files but placed in the wrong folders, and in wp-config.php, themes, plugins and uploads. Sucuri: How to clean a hacked WordPress site

Sucuri lists backdoor functions that appear again and again: base64, str_rot13, gzuncompress, eval, exec, system, assert, stripslashes and move_uploaded_file. Search your files for these terms, then read each match before you delete it.

Check user accounts in every place an attacker could return:

  • WordPress users: go to Users, then All Users, filter by Administrator, and delete any account you do not know
  • FTP and SFTP users in your hosting control panel
  • SSH users and database users listed by your host
  • Email accounts on the hosting plan, which some infections add

Sucuri warns that a cleaned site will quickly become infected again if malicious admin or FTP users stay in place. Delete the unknown accounts and keep only one administrator where you can. Sucuri: How to clean a hacked WordPress site

How do you verify the malware is really gone?

Run the scans again, check the site as a visitor would, and confirm no infected file returns.

MalCare says to use a security scanner after a manual cleanup to confirm no traces are left. If the scanner still finds malware, a plugin cleanup is safer than deleting more code by hand. MalCare: How to remove malware from WordPress

Work through this check list:

  1. Run a full Wordfence or MalCare scan again and read every result
  2. Run Sucuri SiteCheck again and check the blacklist status
  3. Run wp core verify-checksums again if you have SSH access
  4. Open the home page, a post page and the login page in a private browser window
  5. Search Google with site:yoursite.com and look for spam pages that should be gone
  6. Wait a day, then scan once more to catch malware that rebuilds itself

WordPress.org advises changing passwords again after the site is clean, even if you changed them when you found the hack. WordPress.org FAQ: My site was hacked

How do you clear a Google malware warning?

Fix every flagged page first, then ask Google to review the site in Search Console.

Google Search Central says the Security Issues report in Search Console shows any hacked pages Google found on your site, with steps to fix the problem. Open Search Console, then Security and Manual Actions, then Security issues, and read the sample URLs it lists. Google Search Central: Preventing malware infection

Do not request a review until the whole site is clean. Google advises fixing the issue on every page, since fixing only some pages will not bring back search results. If your host suspended the site, ask the host to lift it first.

Once the site is clean, click Request Review in the Security issues report and describe what was wrong and what you fixed. If Google flagged the site, check whether search traffic fell and read our guide on how to check if a WordPress site is penalized while you wait for the review.

When should you get professional help with malware removal?

Get help if you cannot reach wp-admin, if the malware returns after a full cleanup, or if customer data was involved.

Sucuri says that if you are not familiar with database tables or editing PHP, you should seek help from a professional incident response team. Manual database edits can break a site fast when a row is deleted by mistake. Sucuri: How to clean a hacked WordPress site

Before you hire anyone, gather your scan reports, the list of changed files and the date the problem started. To plan the cost, read our guide on how much it costs to hack-clean a WordPress site.

What mistakes should you avoid?

The most common mistake is cleaning the visible symptom and leaving the way in open.

Do not restore a backup without closing the hole the attacker used, or the same attack will work again. Update WordPress, every plugin and every theme once the site is clean, since WordPress.org says older versions are more open to hacks than newer ones.

Do not change passwords once and stop. Change them again after the cleanup, and reset the secret keys in wp-config.php so old sessions end. WordPress.org lists every access point to change: FTP or SFTP, wp-admin, the hosting control panel and the database, for every user with access.

Do not trust a single clean scan. A remote scan cannot see server files, and a free Wordfence scan can miss new malware for 30 days while its signatures catch up. Run a second scan type and check the files by hand.

Do not delete files or database rows you cannot identify. Some backdoor terms also appear in normal plugin code, and deleting the wrong row can break the site. Keep the infected backup, test after each change, and get help if a file or row looks unclear.

Frequently asked questions

Can I remove WordPress malware without a security plugin?

Yes, but it is slow and risky unless you know PHP and SQL well. You must compare every core, theme and plugin file with a fresh copy of the same version, search the database for injected code, and hunt for backdoors by hand. A missed backdoor brings the infection back, so most site owners should use a scanner first and keep manual work for files the scanner flags.

How long does it take to remove malware from WordPress?

A plugin auto-clean can finish in minutes once the scan is done, while a manual cleanup often takes several hours across files, the database and user accounts. The time depends on how many files are infected, whether the database holds spam, and whether the malware returns after the first pass. Allow a full day for checks, a rescan and a Google review if the site was flagged.

Will restoring a backup remove WordPress malware?

Only if the backup was made before the hack started. A backup taken after the attacker got in may hold the same malware. Restore the clean backup, then update everything, change all passwords and reset the secret keys, so the attacker cannot walk back in through the same hole. Scan the restored site before you call it clean.

Why does malware keep coming back after I clean my site?

It returns when a backdoor, a rogue admin user, a scheduled task or an infected file is left behind. Each copy can rebuild the others, so a one-file fix rarely lasts. Clean the files, the database, the user list and scheduled tasks in one pass, then update the software that let the attacker in and change every password after the site is clean.

Is it safe to delete PHP files from the uploads folder?

Yes, in almost every case. The uploads folder should hold images, documents and other media, not PHP files. A PHP file there is very likely a backdoor or a shell. Delete it, then scan again and check how it got there, since removing the file alone does not close the hole that let the attacker upload it.

Do I need to change all passwords after removing malware?

Yes. Change the WordPress admin passwords, hosting control panel, FTP or SFTP, SSH and database passwords, and reset the secret keys in wp-config.php. Do it again after the site is confirmed clean, because a password changed while the site was still infected may already be known to the attacker. Keep the new passwords long, complex and unique.

Sources

  1. FAQ My site was hacked WordPress.org
  2. How to Remove Malware and Fix a Hacked WordPress Site Sucuri
  3. Wordfence Help Documentation Wordfence
  4. How to Remove Malware from WordPress Site Effectively MalCare
  5. Preventing malware infection Google Search Central
  6. wp core verify-checksums WordPress Developer Resources
  7. Sucuri SiteCheck Sucuri

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

WPLegible editors

Researched from the primary sources listed above and checked against our editorial rules. About the site · How we test