Website security directly affects search visibility, user trust, and Google AdSense eligibility: compromised WordPress sites routinely suffer injected spam redirects, hidden cloaked pages that trigger Google Safe Browsing warnings, and sudden deindexation. Effective hardening avoids heavy bloat or fear-driven security plugins that break legitimate bots—relying instead on strict access hygiene, integrity checks, and a clear recovery sequence.
Baseline Hardening Settings Every WordPress Site Should Verify
| Security Control | Recommended Configuration | Practical Purpose |
|---|---|---|
| File Permissions | Directories 755, standard files 644, wp-config.php tightened to 600 or 640 | Prevents unauthorized local processes from reading database credentials or modifying core templates |
| User Accounts & 2FA | Enforce strong unique passwords + TOTP 2FA on Administrator accounts; remove unused admin users | Blocks credential-stuffing attacks against wp-login.php and XML-RPC endpoints |
| API & MCP Integrations | Review Application Passwords and OAuth grants periodically; revoke unused integrations | Limits remote REST API write tokens strictly to active, trusted workflows |
| HTTP Security Headers | Emit X-Content-Type-Options: nosniff, Referrer-Policy, and safe X-Frame-Options: SAMEORIGIN | Mitigates MIME-type sniffing and clickjacking without breaking legitimate ad/analytics frames |
Step 1: Verify Core and Plugin File Integrity Using WP-CLI Checksums
Before assuming an unexplained file change or slow dashboard means a plugin bug, verify whether core WordPress files match official cryptographic hashes from WordPress.org:
# Compare local WordPress core files against official WP.org checksums
wp core verify-checksums
# Verify WordPress.org repository plugins cleanly
wp plugin verify-checksums --allAny unexpected mismatch inside wp-admin/, wp-includes/, or unrecognized .php files placed inside wp-content/uploads/ requires immediate inspection before cleaning or restoring from a verified backup.
Step 2: Post-Incident Triage and Safe Recovery Sequence
If unauthorized modifications, spam drafts, or suspicious redirects are detected, treat recovery as a disciplined containment pipeline rather than random file deletion:
- Capture Forensic Evidence First: Export a copy of recent access logs and database snapshot before overwriting files so you can identify the entry vector (for example, an outdated plugin vulnerability or compromised password).
- Rotate All Credentials & Security Salts: Change hosting panel, SSH/SFTP, database, and Administrator passwords, revoke active WordPress sessions across all users, and regenerate WordPress authentication keys and salts inside
wp-config.php. - Restore Clean Code from Verified Sources: Reinstall WordPress core files and repository plugins cleanly rather than trying to hand-edit potentially obfuscated malware backdoors, then reapply verified custom child theme code.
- Audit Search Visibility & URL Hygiene: Check for unauthorized spam posts, rogue Search Console HTML verification files in the webroot, modified
robots.txtrules, or injected<script>tags inside database posts or theme headers.
Step 3: Protecting Crawler & AdSense Access During Hardening
Overly aggressive firewall or anti-bot settings frequently cause unintended SEO damage. Specifically, avoid blocking legitimate Googlebot or Mediapartners-Google IP ranges, avoid setting X-Frame-Options: DENY globally if it interferes with embedded previews, and confirm interactive tools and analytics still render cleanly using How to Verify Googlebot and Diagnose Crawling Errors.
After recovery, inspect Google Search Console under Security & Manual Actions and re-check your XML sitemaps and robots.txt rules to confirm search engines see a clean domain.
Limitations & Common Hardening Pitfalls
- False Confidence from Changing Login URLs Alone: Obscuring
wp-login.phpdoes not protect outdated plugins or weak admin passwords; enforce updates, least privilege, and 2FA first. - Leaving Untrusted
.phpExecution Enabled Inside Uploads: Most modern WordPress hosts support blocking direct PHP execution insidewp-content/uploads/cleanly via server rules—verify your rule does not break valid WebP/SVG/image delivery.

