Finding out your website has been hacked is a horrible moment. Your stomach drops, your mind races, and the urge is to click anything that looks like a fix. Slow down. How to fix a hacked WordPress site is a process, not a single button — and the people who recover fastest are the ones who work through it in order instead of panicking. Most hacked WordPress sites can be fully cleaned and secured by following a calm, ordered process, and this guide walks you through exactly that, in the order an experienced site owner would actually do it.
You will learn how to confirm the hack, protect your visitors, clean the files and database, lock every door the attacker used, and harden the site so it does not happen again. None of the steps need advanced technical skills. They need patience, a good backup habit, and the willingness to test your work before declaring the job done.
Confirm Your Site Is Really Hacked
Before you delete anything, make sure you know what you are dealing with. Common signs of a hack include strange new admin users, posts or pages you never wrote, visitors redirected to spam or pharmacy sites, a warning from Google in search results, or a suspension notice from your host. Some hacks are subtle, such as hidden spam links that only search engines can see, or code injected into pages that looks normal in the dashboard.
Check the site from a different device and in a logged-out browser, because some malware only shows itself to visitors, not to administrators. If your host reported the hack, read their message carefully — it may name the infected files or the entry point, which saves you hours of guessing. Write down everything you observe: the date you found it, the strange URLs, the warning messages. These notes matter later, when you talk to your host or request a review from Google.

- New unknown admin users or content you never published
- Visitors redirected to spam or pharmacy sites
- Google Safe Browsing warnings in search results
- A suspension notice from your hosting company
- Your site suddenly ranking for strange keywords, like cheap medicines or casino links
One important distinction: a hacked site and a broken site are not the same thing. If your pages show errors after an update, that is usually a plugin conflict, not an attack. The signs above — unknown users, redirects, warnings — are the ones that point to a real intrusion.
Take the Site Offline and Back Up the Evidence
Your first job is to protect your visitors. Put the site into maintenance mode, or ask your host to restrict access while you work. This stops the malware from reaching real people and stops search engines from indexing the hacked pages any further. Most hosts will do this for you within minutes if you open a support ticket and say the site is compromised.
Next, take a full backup of the hacked site before you clean anything — files and database together. It feels strange to back up an infected site, but if cleaning deletes something important, this copy is your only way back. Store it separately from your normal backups and label it clearly as the infected copy, with the date, so nobody restores it by accident six months from now.
- Enable maintenance mode or ask your host to restrict access
- Back up files and database before cleaning anything
- Label the backup clearly as the infected copy, with the date
- Note the date you discovered the hack and what you observed
If you already have a clean backup from before the hack, keep it safe — it may become your fastest route back. Do not restore it yet, though. Restoring over an infected database without cleaning first just brings the malware back, and restoring too early can overwrite evidence about how the attacker got in.
How to Fix a Hacked WordPress Site: Clean the Files and Database
The most reliable cleanup replaces everything replaceable. Trying to scrub infected files one by one is slow, and a single missed backdoor means the hack returns within days. Fresh copies from official sources are faster and safer. Work through these four steps in order.
1. Reinstall WordPress Core From a Fresh Copy
Delete the WordPress core folders — wp-admin and wp-includes — plus every loose file in the site root except wp-config.php and the wp-content folder. Then upload a fresh copy of WordPress from wordpress.org. This removes any malicious code hiding in core files in one move. If you have never done a manual install before, our guide to installing WordPress manually walks through the same file handling step by step.
2. Reinstall Every Theme and Plugin From Official Sources
Delete every theme and plugin, then reinstall them from wordpress.org or the original developer — never from a backup copy, which may itself be infected. Keep only the themes and plugins you actually use; this is a good moment to throw out the ones you installed once and forgot. Pirated “free” copies of premium plugins are one of the most common infection routes, so if a plugin came from anywhere other than the official source, delete it and buy or replace it properly.
3. Scan the Uploads Folder Carefully
The uploads folder is the one part of wp-content you cannot simply reinstall, because it holds your images and media. It is also the favourite hiding place for backdoor scripts, because it is rarely checked. Scan it with a reputable security plugin or your host’s scanner, and look for PHP files sitting among your images — a .php file in uploads is almost always malicious, because images do not need executable code. Delete anything suspicious, and re-upload any media you are unsure about from your own computer.
4. Clean the Database
Open the database and check for unknown admin accounts, especially any user with the administrator role that you do not recognise — delete those. Search the posts and options tables for injected content, such as spam links hidden in post content or strange URLs in the site settings. If database work feels beyond you, this is the step to hand to a professional or your host’s support team: a wrong edit here can break the site, while a missed injection brings the hack straight back.

- Reinstall WordPress core from a fresh official copy
- Reinstall themes and plugins only from official sources
- Delete unknown admin accounts from the database
- Scan uploads and database for injected code and backdoors
When the scan comes back clean, do not celebrate yet. Run it a second time with a different scanner if you can — different tools catch different things, and a second clean result is worth far more than one.
Reset Every Password and Key
Cleaning files is useless if the attacker still knows a password. Change every WordPress admin password, your hosting account password, your database password, and any FTP or SFTP credentials. Use long, unique passwords stored in a password manager — a password you reuse across sites is a password the attacker already has.
Also reset the secret keys in your wp-config.php file. WordPress generates eight authentication keys and salts in that file, and resetting them forces every user to log in again, which kills any stolen login cookies the attacker is holding. You can generate fresh keys from the official WordPress secret-key service and paste them in, replacing the old block. It takes two minutes and closes a door many people forget exists.
Enable two-factor authentication for all administrator accounts. With 2FA turned on, a leaked password alone is no longer enough to get in — the attacker would also need your phone. Every major security plugin offers this, and it is the single highest-value change you can make after a hack.
- Change all admin, hosting, database, and FTP passwords
- Reset the WordPress secret keys in wp-config.php to force every user to log in again
- Enable two-factor authentication for all administrator accounts
- Remove every account nobody on your team recognises
Harden the Site So It Does Not Happen Again
Most WordPress hacks exploit outdated plugins or themes, weak passwords, or a missing security layer — so prevention is mostly discipline. Here is the routine that keeps a cleaned site clean.
Keep Everything Updated, Including PHP
Turn on automatic updates for plugins and themes where you can, and apply WordPress core updates promptly. The same applies to the server itself: an old PHP version can carry known vulnerabilities, so keep it current. Our guide to updating the PHP version in WordPress shows how to check your version and switch it safely from your hosting panel.
Delete What You Do Not Use
Every inactive plugin and unused theme is an unlocked window. Delete them completely — deactivating is not enough, because the files stay on the server and can still be exploited. If you have not used a plugin in three months, you do not need it.
Keep a Firewall and Malware Scanner Active
A security plugin with a firewall blocks many attacks before they reach WordPress at all, and a scheduled malware scan catches anything that slips through. Set the scanner to run daily and to email you the results. You want to hear about the next intrusion attempt from your scanner, not from a customer.
Fix Warnings and Keep Off-Site Backups
If Google flagged your site, request a review through Search Console once cleaning is complete — the warning usually clears within a few days of a clean review. If your browser showed certificate warnings, check that your SSL setup is correct; our guide to fixing SSL certificate errors on WordPress covers the common causes. And keep off-site backups running permanently, because a clean recent backup turns the next incident, if it ever comes, into an inconvenience instead of a crisis.

- Enable automatic updates for plugins, themes, and PHP
- Delete unused themes and plugins completely
- Keep a firewall and malware scanner active with daily scans
- Maintain off-site backups permanently
Frequently Asked Questions
How did my WordPress site get hacked?
The most common causes are outdated plugins or themes with known vulnerabilities, weak or reused passwords, and pirated premium plugins that contain hidden malware. In most investigations, the entry point is an update that was never applied — the vulnerability was public, the fix was available, and the site simply had not installed it.
Can I clean a hacked site myself?
Yes, many owners do, by reinstalling clean copies of everything, removing unknown accounts, and resetting all passwords. The steps in this guide are the same ones professionals follow. If your store handles payments, or the hack keeps returning after a full cleanup, professional cleaning is the safer choice.
Why does the hack keep coming back after cleaning?
Usually a backdoor file was missed, often hidden in the uploads folder, or a password was not changed. Reinfection almost always means one hiding place or one credential survived the first cleanup. Go back through the steps in order: re-scan uploads, check the database for unknown admins, and confirm every password and secret key was actually reset.
How long does it take to fix a hacked site?
A straightforward cleanup takes a few hours of focused work, plus time for Google to review and remove warnings, which can take several days. Complex or repeated infections take longer to investigate properly. If your site earns money, schedule the work for your quietest hours and tell anyone affected what you are doing.
After the Cleanup: What to Check Before You Relax
You now have a clear path through how to fix a hacked WordPress site from start to finish. Before you call the job done, test your site the way a stranger would: on a phone, logged out, clicking the same links and forms your visitors use every day. Problems that are invisible in the dashboard often show themselves immediately in a real visit, and catching them yourself is far better than hearing about them from a customer.
Work through the steps in order, check your results as a real visitor would, and keep your site maintained afterwards. Keep notes as you go, even if they are just a few lines in a document — recording what you changed and when makes it far easier to undo a mistake, explain the problem to a support team, or repeat the same process on another website in the future.
Remember that your hosting company’s support team deals with this exact situation every day. If a step fails twice, contacting them with a clear description of what you tried is not giving up; it is using a resource you already pay for, and it often saves hours of frustration. That steady, careful approach is what separates websites that quietly grow from websites that lurch from one emergency to the next.

