Quick answer: if your WordPress site is hacked, do these in order: (1) take a backup of the hacked site as evidence, (2) change every password (hosting, cPanel, database, WordPress admins, FTP/SFTP), (3) put the site in maintenance mode, (4) scan the files and database to find the infection, (5) replace WordPress core, plugins and themes with clean copies, (6) delete unknown admin users and malicious files, (7) update everything and harden the login, then (8) ask Google to review the site if it was flagged. Restoring an old backup alone usually brings the hack back, because the hole that let the attacker in is still open.
Signs your WordPress site has been hacked
- Visitors (often only on mobile, or only from Google) are redirected to spam, betting, adult or fake prize sites.
- Google shows “This site may be hacked” or Chrome shows a red “Dangerous site” warning.
- Search results show pages you never made, often in Japanese or with pharmacy or casino keywords.
- New administrator accounts you don’t recognise appear under Users.
- Your host suspends the account or emails you about malware or spam sending.
- The site is suddenly very slow, or you see unknown PHP files in
wp-content/uploads. - Your emails start landing in spam because your domain or server got blacklisted.
Step 1: Don’t panic, and don’t delete anything yet
Take a full backup of the hacked site (files and database) before you touch it. You’ll need it to see what changed, and as a fallback if a clean-up step breaks something. Most hosting control panels can download a full backup, or you can use a backup plugin if you can still log in.
Step 2: Change every password
Assume every password connected to the site is known to the attacker. Change them from a clean device:
- Hosting account and cPanel (or equivalent)
- FTP/SFTP and SSH accounts
- The database user (then update
wp-config.phpwith the new password) - Every WordPress administrator, and editors too
- The email account that receives WordPress password resets
Also generate new WordPress security keys and salts in wp-config.php. This logs everyone out, including the attacker.
Step 3: Find the infection
- Run a malware scan with a reputable security plugin, or use your host’s scanner. Many Sri Lankan and international hosts include one in cPanel.
- Check Users for administrators you didn’t create.
- Look for recently modified files, and for PHP files inside
wp-content/uploads(there should be none). - Check
.htaccess,wp-config.phpandindex.phpfor injected code, especially long encoded strings andevalorbase64_decode. - In the database, check the
wp_optionstable (siteurl, home, active_plugins) and search posts for injected<script>tags or spam links. - In Google Search Console, open Security issues to see what Google found.
Step 4: Replace, don’t patch
Hand-editing infected files is how hacks come back. Instead:
- Replace WordPress core: download a fresh copy from WordPress.org and replace
wp-adminandwp-includescompletely. - Delete and reinstall every plugin and theme from the official source. Remove anything you don’t use.
- Remove “nulled” (pirated) premium plugins or themes completely. They are one of the most common ways WordPress sites get infected. Buy the licence or replace them.
- Keep only your uploads (images and documents) and remove any
.phpfiles found inside them. - Clean the database entries you found in Step 3.
Step 5: Close the door the attacker used
- Update WordPress, every plugin and theme, and move to a supported PHP version.
- Turn on login protection: limit login attempts and enable two-factor authentication for administrators.
- Rename or remove the default “admin” username, and remove accounts that are no longer needed.
- Turn off file editing in the dashboard (
define('DISALLOW_FILE_EDIT', true);inwp-config.php). - Set up automatic, off-site backups (daily for the database, weekly for files) so the next problem is a quick restore.
Step 6: Get your Google rankings and email back
- If Google flagged the site, fix everything, then click Request review under Security issues in Search Console. Reviews usually take a few days.
- Use the Removals tool, or let 404/410 responses do the job, for spam pages that got indexed.
- Check your domain on email blacklists and request delisting once the site is clean.
When to call a professional
Get help if the site keeps getting reinfected, if it takes card payments or customer data, if your host has suspended it, or if Google shows a red warning. Every day with a warning costs you traffic and trust. A proper clean-up usually takes a few hours, and the hardening afterwards is what stops it happening again.
Need your site cleaned and protected?
We clean hacked WordPress and WooCommerce sites, find how the attacker got in, and harden the site so it stays clean. Our website care plans then keep it updated, backed up and monitored. Message us on WhatsApp for urgent help, or send us the details.
FAQ
Can I just restore an old backup?
Restoring a clean backup is a good start, but if you don’t also change passwords and update or remove the vulnerable plugin, the attacker usually gets back in within days.
How did my site get hacked?
The most common causes are outdated plugins or themes with known vulnerabilities, nulled (pirated) plugins, weak or reused admin passwords, and old unused sites on the same hosting account.
Will I lose my Google rankings?
A short, quickly fixed infection rarely causes lasting damage. A site that shows a Google warning for weeks, or gets thousands of spam pages indexed, can lose rankings that take months to recover.
How do I stop it happening again?
Keep everything updated, use two-factor login, remove unused plugins and accounts, never use nulled software, and keep automatic off-site backups.
Recent Posts
- How to Accept M-Pesa Payments on Your Online Store in Kenya (WooCommerce and Shopify)
- WordPress Site Hacked? A Step-by-Step Clean-Up Guide (2026)
- Shopify vs WooCommerce in Sri Lanka: Real Costs and Which to Choose (2026)
- How to Set Up PayHere on WooCommerce (2026 Guide for Sri Lanka)
- How Your Website Turns Visitors Into Paying Customers
