Finding out that your WordPress site has been hacked is stressful, but most infections follow a small number of patterns and can be removed methodically. The order of the steps matters: cleaning before you understand how the attacker got in is the main reason sites are reinfected within days.
Signs that a site is infected
- Visitors are redirected to other sites, often only on mobile or only when arriving from a search engine.
- Google shows a "This site may be hacked" or "Deceptive site ahead" warning, or search results show pages in another language that you never wrote.
- New administrator users that nobody created.
- Unknown files or folders, or core files with recent modification dates.
- Your host suspended the account for sending spam or using too many resources.
Step 1: preserve and contain
Take a full backup of the files and the database as they are, infected. It is your evidence and your safety net if a cleaning step breaks something. Then put the site in maintenance mode or restrict access to your own IP address, and change the hosting, SFTP and database passwords so that the attacker loses the access they may still have.
Step 2: scan from more than one angle
Run a server-side malware scanner, since remote scanners only see what the site shows to visitors. Then verify the integrity of WordPress itself. With WP-CLI:
wp core verify-checksums
wp plugin verify-checksums --all
These commands compare your files with the official copies and list every file that was changed or added.
Step 3: replace, do not repair
- Core: delete the
wp-adminandwp-includesfolders and upload fresh copies of the same version from wordpress.org. Replace the core files in the root folder, keepingwp-config.php. - Plugins and themes: delete each one and reinstall it from the official source. Remove anything you do not use. Never reinstall a "nulled" premium plugin or theme: pirated copies are one of the most common sources of infection.
Replacing whole folders is faster and safer than looking for the injected lines in each file.
Step 4: look where clean copies do not reach
Backdoors are placed in the parts of the site that are unique to you.
wp-content/uploads: this folder should hold media only. Any.phpfile inside it is suspect.wp-content/mu-plugins: "must-use" plugins load automatically and do not appear in the normal plugin list, which makes the folder a favorite hiding place.wp-config.phpand.htaccess: read both line by line for includes, redirects or encoded code that you did not add.- Your theme: if you customized it, compare
functions.phpand the template files with a clean copy.
Step 5: clean the database
- In
wp_users, delete administrator accounts that you do not recognize. - In
wp_options, check thatsiteurlandhomepoint to your domain, and look for unfamiliar entries with long encoded values. - Search
wp_postsfor injected<script>or<iframe>tags. - Review the scheduled tasks (
wp cron event list) for jobs that you did not create: they are used to reinfect the site after cleaning.
Step 6: rotate every secret
Change the passwords of all WordPress administrators, the database user, SFTP and the hosting panel. Generate new authentication keys and salts in wp-config.php, which signs every logged-in session out. If the site stores API keys for payment or email services, rotate those as well.
Step 7: find and close the entry point
Check the access logs around the date of the first modified file. The cause is almost always one of four: an outdated plugin or theme with a known vulnerability, a weak or reused administrator password, a nulled plugin, or another infected site on the same hosting account. Update WordPress, plugins and themes, remove what you do not use and enable two-factor authentication for administrators.
Step 8: clear the warnings
If Google flagged the site, open Search Console, review the Security Issues report and request a review once the site is clean. Check that your domain and server IP address are not on email blocklists, and ask your host to lift any suspension.
Keeping it clean
A cleanup returns the site to the state it was in before the attack, including the weakness that allowed it. Lasting protection needs a firewall in front of the application, monitoring of file changes and someone who reacts when an alert fires at night. See why updates alone are not enough.
Our WordPress security plugin adds a WAF, malware analysis, automated response and recovery, backed by a SOC that watches the site 24 hours a day. For servers that host many sites, SOC AI WebApps covers every site on the server with one subscription.



