Skip to content
24/7 support · 7-day money-back guarantee · Free plan, no card neededSee plans

Blog › PHP and WordPress ›

Hacked WordPress site? A step-by-step SEO recovery guide

Cover image: Hacked WordPress site? A step-by-step SEO recovery guide

A hacked website is a bad day for any owner, and it is also a search problem. Attackers do not break into sites for fun. They want something: spam pages that sell pills or counterfeit goods, hidden links that pass authority to their own sites, redirects that send your visitors to scams, or a place to host malware. Search engines notice, and the consequences can include warnings in results, removed pages and lost traffic. This guide walks through recovery in the right order: stop the damage, clean thoroughly, close the door, then rebuild trust with search engines. It is written for WordPress, but the sequence applies to any site.

Contents of the guide: Hacked WordPress site? A step-by-step SEO recovery guide
The main sections of this guide.

If you suspect your site was affected by the critical PHP flaws patched in October 2026, read our companion article on that incident first. This guide assumes you already know or suspect a compromise.

Signs your site may be compromised

Hacks are not always obvious. Common signs include strange pages appearing in Google when you search for your own domain, titles or descriptions in unfamiliar languages, a browser warning when visitors arrive, redirects on mobile devices that you cannot reproduce on your computer, a sudden spike in traffic from odd places, new admin users you did not create, files you do not recognize, a hosting suspension notice, and Search Console messages about security issues or manual actions.

A useful first test is to search Google for your domain combined with words that spammers favor. If results show pages you never published, you have injected content. Another test is to view your site as a crawler would: some malware only shows spam to search engine bots or to visitors arriving from search results, and hides it from the owner. Fetching a page with a crawler-like tool such as the URL inspection feature in Search Console reveals what Google sees.

Step 1: Contain the incident

Before you clean, limit further harm. Put the site into maintenance mode or temporarily block public access if it is actively serving malware or phishing. Contact your host, because many hosts provide malware scanning, can isolate the account and may have logs that help. Change passwords for everything: WordPress admin users, hosting control panel, FTP and SSH, database and email accounts tied to the site. Do this from a clean computer, since a compromised device can be the original source.

Take a full backup of the infected state, files and database, and store it offline. It looks odd to back up a hacked site, but you need evidence for analysis and a fallback if the cleanup goes wrong.

Step 2: Find how they got in

If you clean without finding the entry point, you will be hacked again. Typical causes are outdated plugins or themes with known vulnerabilities, stolen or weak passwords, nulled premium plugins that arrive pre-infected, vulnerable software on the server such as an unpatched PHP runtime, and shared hosting accounts contaminated by a neighbor. Check your plugin and theme list against vulnerability databases, review user accounts, and read access and error logs from around the first sign of trouble. Your host’s support team can often point to the exploited file.

Step 3: Clean the site

You have two broad options. The first is restoring a clean backup taken before the infection. This is often fastest, but you must be sure the backup is truly clean and then close the entry point before reconnecting, or you will be reinfected. The second is manual or scanner-assisted cleaning.

For manual cleaning, work methodically. Replace WordPress core files with fresh copies from wordpress.org rather than trying to find infected lines. Reinstall every plugin and theme from official sources, deleting the old folders first. Inspect the uploads folder, which should hold media only, and remove any PHP files found there. Search the database for injected scripts, unknown admin users, suspicious options and spam posts. Check the main configuration file, the .htaccess file and any must-use plugin folder, which attackers like because those files load automatically. Delete unfamiliar scheduled tasks.

If this is beyond your comfort, hire a professional cleanup service. A thorough cleanup costs less than repeated reinfections.

Step 4: Close the door

Update WordPress core, all plugins and all themes, and remove anything unused. Update PHP to a supported, patched version. Enforce strong, unique passwords and two-factor authentication for administrators. Limit the number of admin accounts. Disable the theme and plugin file editor in WordPress by adding a constant to the configuration file. Set safe file permissions. Add a firewall at the server, CDN or plugin level. Turn on automatic backups stored away from the server and test restoring one.

Rotate secrets again after cleaning: database password, salts and keys in the configuration file, API keys and any tokens, because attackers may have copied them.

Step 5: Tell search engines you are clean

Once the site is fully clean and secure, use Google Search Console. If you have a Security issues report entry, fix the problem and then use the request review button, explaining briefly what you removed and what you did to prevent recurrence. If you received a manual action for hacked content or spam, the Manual actions report has a similar review request. Be specific and honest in the review text; vague claims slow things down.

Reviews can take days to weeks. Do not submit repeatedly. If a review is rejected, the message usually tells you what remains, so look again for hidden files, cloaked content or reinfection.

Step 6: Remove spam URLs from results

Injected spam pages may stay in the index after you delete them. Make sure they return a 404 or 410 status so search engines learn they are gone. For urgent cases you can use the removals tool in Search Console to temporarily hide URLs, but the real fix is the status code. If spam pages used a predictable pattern, a redirect or a rule that returns 410 for that pattern can clear them faster. Resubmit a clean sitemap so crawlers rediscover your legitimate pages.

Watch the Pages report over several weeks. The number of indexed pages should return to a normal level. Run a site audit to confirm that only the pages you intend are discoverable, and use the meta tag checker on important pages to confirm that titles, descriptions and robots tags are the ones you set. If you use a link report, check outbound links for any you did not add.

Step 7: Rebuild trust and traffic

Recovery does not end when the warning disappears. Rankings may return gradually. Help the process by fixing any remaining technical issues, publishing and updating good content, and checking that your Google Business Profile and other listings are unchanged. If customers were affected, communicate honestly. A short note explaining what happened, what you did and what customers should do builds trust.

Track clicks and impressions weekly in Search Console, and note any pages that do not recover. Sometimes a page lost links or content during the cleanup, and restoring it helps.

What not to do

Do not ignore the problem, hoping it fades. Do not simply delete suspicious files without understanding the entry point. Do not restore a backup without checking that it is clean. Do not pay anyone who promises instant restoration of rankings. Do not use the Google disavow tool unless you have a real link problem, because hacks usually involve outbound links and injected pages, not bad inbound ones. Do not remove your site from the index by blocking crawlers unless you have a specific reason, because that slows recovery.

Prevention routine

Prevention is mostly boring habits. Keep software updated, including PHP. Use a reputable host. Back up daily and test restores. Use unique passwords and two-factor login. Keep the plugin list short. Monitor Search Console for security alerts and unusual indexing changes. Run a monthly audit, and watch your 404 monitor for sudden clusters of unusual URLs, which can signal injected pages or scanning.

A checklist you can print

  1. Contain: maintenance mode, contact host, change passwords.
  2. Back up the infected state for analysis.
  3. Identify the entry point.
  4. Clean or restore, then reinstall core, plugins and themes from official sources.
  5. Update everything and harden.
  6. Rotate secrets and keys.
  7. Check Search Console for security and manual action issues, and request review.
  8. Make spam URLs return 404 or 410 and resubmit the sitemap.
  9. Monitor for reinfection and for traffic recovery.
  10. Document what happened and add the prevention routine to your maintenance plan.

Frequently asked questions

How long does SEO recovery take after a hack? It varies. Warnings can clear within days of a successful review, while rankings may take weeks or months to recover fully, depending on how long the site was affected and how much content was lost.

Will Google penalize me forever? Hacked-site actions are not meant to be permanent. Once the site is clean and secure, a review removes them, and normal ranking signals resume.

Should I change my domain? Almost never. A clean domain recovers. Changing domains adds new problems.

Can a plugin fix everything automatically? Security plugins help detect and block, but they cannot guarantee a complete cleanup. Use them as part of a process.

Is the PHP version part of the problem? It can be. Unpatched PHP has caused serious exposure, and running unsupported branches leaves flaws open. Keep PHP on a supported, patched version.

Keep reading

Comments

Leave a comment

Check your own site

Run a free audit and see what to fix first.

Run a free audit