Finding out that your WordPress website has been hacked is stressful. Pages may redirect to strange sites, strange links may appear in your content, your hosting company may have suspended the site, or Google may be warning visitors away. It is tempting to panic or to start deleting files at random. Do not do either. A hacked WordPress site can usually be recovered, and the process is straightforward if you work through it calmly, one step at a time.
Step 1: Protect your visitors and take the site offline safely
Your first job is to stop the hacked site from harming visitors. If your site is redirecting people to scam pages or serving malware, every hour it stays live puts your visitors and your reputation at risk. Put the site into maintenance mode or take it offline temporarily. Many hosts offer a one-click maintenance mode, and a simple coming soon plugin will do the same job.
Next, tell your hosting company what has happened. Hosts deal with hacked sites every day, and they can often help: they may have server logs that show when the attack happened, they may be able to restore a clean backup, or they may scan the account for infected files. Ask them when the site was first compromised if they can tell, and ask whether the problem is limited to your site or affects other sites on the same account.
Do not delete everything in a panic. Before you change anything, make a full backup of the site exactly as it is, including the database, even though it is infected. This sounds strange, but that backup is your safety net. If cleaning goes wrong, you can restore it and start again. Label the backup clearly as infected so nobody restores it by mistake later.
Step 2: Change your passwords from a clean computer
Before you start cleaning, change your passwords, and do it from a computer you trust is clean. If your own computer has malware, changing passwords on it may simply hand the new ones to the attacker. If you have any doubt about your computer, run a full antivirus scan first, or use a different device.
Change the passwords for your WordPress admin accounts, your hosting control panel, your database, and the email account linked to the site. Use a different strong password for each one, and store them in a password manager. If several people have admin access, ask each of them to change their password too, and remove any admin accounts you do not recognise. Attackers often create a hidden admin user so they can return later, and removing it is an essential part of the cleanup.
If your site uses FTP or SSH, change those passwords as well, and check for any unfamiliar FTP accounts in your hosting control panel. The same goes for any API keys stored on the site. The rule is simple: assume every password connected to the site may be known to the attacker, and replace them all.
Step 3: Clean the site by hand when there is no clean backup
Manual cleaning starts with a fresh copy of WordPress itself. Download a fresh copy of WordPress, and replace the core folders, wp-admin and wp-includes, and the core files in the site root. Do not touch wp-config.php or the wp-content folder yet. Fresh core files remove any malicious code hidden in WordPress itself.
Next, look at your themes and plugins. Delete any theme or plugin you are not using. For the ones you keep, delete them and reinstall fresh copies from the official WordPress directory or the original developer. Reinstalling is safer than trying to edit infected files, because malicious code can hide in places that are easy to miss. Check the uploads folder for suspicious files too, especially files with odd names or files that should not be there, such as PHP files inside the uploads folder.
Then scan the database. A security plugin can scan the database for suspicious entries, including spam links and hidden admin users. Look through your posts and pages for content you did not add, and check the site settings for changed titles, changed admin email addresses, and unexpected redirects. If your site was redirecting visitors, check the .htaccess file and wp-config.php for added code, and compare them against clean copies.
Cleaning by hand takes patience. Work through the site folder by folder, and do not skip the parts that look fine. Attackers hide code in ordinary-looking files, and one missed file can reinfect the whole site. If the infection keeps returning after cleaning, the cause is usually a missed backdoor file or an unpatched plugin, so go back and check those first.
Step 4: Find and close the way the attacker got in
Cleaning the site is only half the job. If you do not close the entry point, the attacker will return. The most common entry points are an out-of-date plugin or theme, a weak admin password, and a compromised computer. Update WordPress, every theme, and every plugin to the latest version, and delete anything you do not use. An unused plugin that is out of date is still a risk, because its code is still on the server.
Review every user account on the site. Remove accounts that should not exist, reduce the number of administrators to the smallest number you need, and give other users the lowest role that lets them do their work. Turn on two-factor authentication for admin accounts if your site supports it. Limit login attempts so automated password guessing is blocked, and change the login page address if that suits your setup.
Finally, set up regular automatic backups stored away from your hosting account, and a routine for updating plugins and themes. A backup you can rely on turns the next incident from a crisis into a short job. If you would rather have a professional handle the cleanup and the hardening, our WordPress services cover security cleanups and ongoing care.
Frequently asked questions
Can a hacked WordPress website be fully recovered?
In most cases, yes. A clean backup restores the site quickly, and a careful manual cleanup can remove the infection when no backup exists. The key is to work methodically, remove the entry point, and check the site thoroughly before putting it back online.
How long does it take to recover a hacked WordPress site?
A backup restore can take an hour or two. A manual cleanup usually takes several hours, depending on the size of the site and how deeply the infection has spread. Larger sites with many plugins take longer, because every file and every plugin needs checking.
Should I pay a ransom or the hacker to fix the site?
No. Paying does not guarantee the site will be fixed, and it marks you as someone willing to pay. Recover the site from a backup or clean it by hand, and if the damage is beyond your skills, hire a professional to do the cleanup.
How do I know the hack is really gone?
Scan the site with a reputable security plugin, check your pages and database for unfamiliar content, and watch the site for a few days after recovery. If redirects, spam links, or strange admin users come back, a backdoor file was missed and the cleanup needs another pass.
If your WordPress website has been hacked and you need help recovering it safely, contact Shehryar Noor — a web designer and developer since 2018 who has built more than 80 websites, and can clean up your site and secure it properly.