How do I protect my WordPress site from hackers?

SEO & GEO for WordPress websites

WordPress powers a substantial share of the internet, which makes it an attractive target for automated attacks. Roughly 13,000 WordPress sites are compromised every day, and the majority of successful attacks exploit plugins, weak credentials, or misconfigured server settings rather than WordPress core itself. The good news is that most of these attacks are preventable with a consistent, layered approach to security.

This guide walks you through seven concrete steps to protect your WordPress site from hackers in 2026. Each section covers what to do, how to verify it worked, and what to watch out for along the way.

Essential security tools and access you need first

Before making any security changes, gather the tools and access you will need. Skipping this preparation step is one of the most common reasons security hardening goes wrong.

  • Hosting control panel access (cPanel, Plesk, or your managed host’s dashboard) for PHP version management and file permissions
  • FTP or SFTP credentials to access and edit server files directly
  • An off-site backup of your entire WordPress installation, stored in cloud storage or a separate server. A backup stored on the same server as WordPress offers no protection if that server is compromised.
  • Google Search Console connected to your site. The free tool alerts you to malware detections, spam injections, and ranking drops, giving you an early warning system that most site owners overlook.
  • An active SSL certificate providing HTTPS. Most managed WordPress hosting providers include this by default via Let’s Encrypt. If yours does not, enable it before proceeding.
  • PHP 8.x running on your server. Older PHP versions no longer receive security patches. Check and upgrade through your hosting control panel, testing plugin and theme compatibility first.

Confirm each item on this list before moving to the next section. If your backup is missing or your PHP version is outdated, address those first. The steps that follow assume these foundations are in place.

Update WordPress core, themes, and plugins

Keeping WordPress, its themes, and its plugins up to date is the single highest-impact security action you can take. In 2025, over 11,000 new vulnerabilities were identified across the WordPress ecosystem, with the overwhelming majority located in plugins rather than WordPress core. The window between a vulnerability being disclosed and attackers exploiting it at scale can be as short as a few hours, so patching promptly is not optional.

  1. Navigate to Dashboard > Updates in wp-admin. You will see three sections: WordPress core, plugins, and themes.
  2. Apply any available core updates first. Minor security releases run automatically by default; major updates may require manual confirmation depending on your configuration.
  3. Update all plugins. Select all and click “Update Plugins.” For large sites managing multiple installations, a tool like WP Umbrella lets you push updates across every site from one portal.
  4. Update all themes, including inactive ones.
  5. Delete any plugins or themes you no longer use. Deactivated plugins that remain installed still represent an attack surface because their files are accessible on the server.

To reduce the manual effort going forward, enable automatic updates for individual plugins from the Plugins screen in wp-admin. You can also enable them globally via the WP_AUTO_UPDATE_CORE constant in wp-config.php. After enabling automatic updates, check Tools > Site Health to confirm WordPress Cron is running correctly, since auto-updates depend on it.

One important limitation: recent vulnerability research shows that nearly half of disclosed vulnerabilities have no developer patch at the time of disclosure. Updates are essential but not sufficient on their own. The sections on WAF configuration and malware scanning below address that gap.

Harden your login page against brute-force attacks

WordPress allows unlimited login attempts by default. There is no built-in rate limiting or brute-force protection in WordPress core, which means automated bots can hammer your login page indefinitely until they find a working combination. Hardening the login page closes that gap.

Enable two-factor authentication

Two-factor authentication (2FA) is the most effective single control against credential-based attacks. Even if an attacker obtains a valid password, they cannot complete the login without the second factor. WordPress does not include 2FA natively, so you need to add it via a plugin. Recommended options include TOTP authenticator apps (Google Authenticator, Authy), hardware security keys, or passkeys using the WebAuthn standard. Apply 2FA to all administrator accounts at minimum.

Limit login attempts

Install a plugin like Limit Login Attempts Security to cap failed login attempts before a lockout triggers. A sensible starting configuration is five failed attempts before a lockout, with escalating lockout durations for repeat offenders. Configure the plugin to immediately lock out any attempt using “admin” or “administrator” as the username, since no legitimate user on a properly configured site should be using those usernames.

Add CAPTCHA and review XML-RPC

Add a CAPTCHA or Turnstile challenge to the login form. Cloudflare Turnstile and Google reCAPTCHA both integrate with WordPress via plugins and add meaningful friction for automated bots without frustrating real users. Additionally, review whether your site uses XML-RPC. If you do not use it for mobile apps or external integrations, disable it entirely, since it is a common brute-force target that bypasses the standard login page.

After completing these steps, attempt a test login with intentionally wrong credentials five times and confirm the lockout triggers as expected. Check the plugin’s log to confirm the attempt was recorded.

Configure a web application firewall (WAF) for WordPress

WordPress has no built-in firewall. A web application firewall (WAF) sits between incoming traffic and your site, inspecting HTTP requests for attack patterns such as SQL injection, cross-site scripting, and credential stuffing before they reach WordPress. Standard hosting defenses alone block a small fraction of exploits, which is why a dedicated WAF is a non-negotiable layer in a serious security setup.

Choose the right WAF deployment model

There are three main WAF types for WordPress, each with different trade-offs:

  • DNS-level cloud WAF (Cloudflare, Sucuri): Filters traffic at the network edge before it reaches your server. Excellent for DDoS mitigation and performance. Limitation: if an attacker discovers your server’s origin IP address, they can bypass the cloud WAF by connecting directly to the server.
  • Endpoint/plugin-based WAF (Wordfence, NinjaFirewall): Runs inside WordPress and has deep visibility into user sessions, authentication states, and application logic. Wordfence protects over five million WordPress sites and is the most widely deployed option. The free tier is solid; the premium tier adds real-time threat intelligence.
  • Host-bundled WAF: Provided by managed WordPress hosting platforms as part of the hosting environment. Convenient but varies significantly in quality between providers.

Configure your chosen WAF

  1. Install your chosen WAF plugin or configure your DNS-level provider according to its official documentation.
  2. Enable blocking rules for high-confidence attack signatures (SQL injection, XSS, file inclusion).
  3. Set rate limits tuned to realistic usage patterns for your site. Overly aggressive rate limits generate false positives and block legitimate visitors.
  4. Add bypass rules for core WordPress flows: wp-login.php (for your own admin access), the REST API, and admin AJAX. Without these, the WAF can interfere with normal WordPress functionality.
  5. Connect WAF logs to your monitoring setup alongside PHP error logs and WordPress audit logs.

Consider combining an endpoint WAF with a DNS-level layer. Security research from 2026 consistently finds that no single plugin matches the combination of in-application protection plus an always-on edge WAF with current vulnerability coverage. Do not run two competing security plugins simultaneously. Two firewalls do not double protection; they create conflicts and can crash your site.

Secure file permissions and disable dangerous PHP execution

File permissions control who can read, write, and execute files on your server. Incorrect permissions are one of the most exploited server-level vulnerabilities, and attackers in 2026 increasingly automate permission probing to find misconfigured directories.

Set the correct permission baseline

  1. Connect to your server via SFTP or SSH.
  2. Set all WordPress directories to 755 (owner can read/write/execute; group and public can read/execute).
  3. Set all WordPress files to 644 (owner can read/write; group and public can read only).
  4. Set wp-config.php to 400 or 440. This file stores your database credentials in plaintext, so it should be readable only by the server owner.
  5. Never use 777 permissions on any file or directory. A 777 permission grants full read, write, and execute access to every user on the server.

Disable PHP execution in the uploads directory

The most common file-based attack involves uploading a PHP file disguised as an image, then executing it by visiting its URL. WordPress does not need PHP to execute inside the wp-content/uploads directory, so you can block it entirely at the server level.

  1. Create a file named .htaccess inside your /wp-content/uploads/ directory.
  2. Add rules to deny execution of PHP files within that directory. Your hosting provider or a security plugin like Wordfence can generate the correct syntax for your server configuration.
  3. Verify the rule works: upload a harmless test PHP file to the uploads directory and attempt to access it via browser. If the file executes, the rules were not applied correctly. Delete the test file immediately after verification regardless of outcome.

This server-level configuration persists independently of WordPress. If a security plugin is deactivated, the .htaccess rule remains in effect. Additionally, add define('DISALLOW_FILE_EDIT', true); to wp-config.php to disable the built-in theme and plugin editor in the WordPress dashboard. If an attacker gains admin access, this prevents them from injecting code through the editor.

Set up automated malware scanning and alerts

Manual security checks are not enough. In 2026, attackers inject malicious code directly into legitimate WordPress core, plugin, and theme files rather than dropping standalone malicious files. Traditional approaches that only look for unfamiliar files miss this technique entirely. Automated scanning catches what manual reviews cannot.

Choose a scanner matched to your hosting environment

The right malware scanner depends on your server resources:

  • Wordfence: On-server scanner that compares core files, themes, and plugins against verified originals. Deepest file-level scanning available, but can spike CPU usage significantly on shared or budget hosting.
  • MalCare: Offloads scanning to its own cloud servers, keeping your server load minimal. Offers one-click automated malware removal. A strong choice for shared hosting environments.
  • Sucuri: Remote scanner plus server-side scanner, with a malware cleanup service. Its free remote scanner has detection limitations, but the paid service is comprehensive.
  • Patchstack: Focused on vulnerability detection and virtual patching rather than file scanning. Patchstack adds firewall rules targeting specific plugin and theme vulnerabilities as soon as they are disclosed, often before a developer patch is available. Pair it with a file scanner for full coverage.

Configure alerts and monitoring

  1. Enable real-time alerts for malware detection, file changes, failed logins, and blacklist status changes.
  2. Install an activity logging plugin such as WP Activity Log to track admin-level actions and spot suspicious behavior.
  3. Monitor your site’s blacklist status through the Security Issues tab in Google Search Console. A site blacklisted by Google loses the vast majority of its organic traffic almost immediately.
  4. Set up uptime monitoring so you are alerted if the site goes offline, which can indicate a successful attack or a server-level compromise.

A practical plugin stack for most sites in 2026 is one primary security suite (Wordfence, MalCare, or Sucuri) combined with Patchstack for vulnerability intelligence. Keep the stack lean. Running too many overlapping security plugins creates conflicts and performance problems that can outweigh the security benefit.

Verify your defenses are working correctly

Configuring security measures is not the same as confirming they work. Verification closes the gap between what you believe is protected and what is actually protected.

Run a vulnerability scan

WPScan is the dedicated WordPress vulnerability scanner used by security professionals. It is free for non-commercial use, enumerates your WordPress version, plugins, themes, and usernames, and flags outdated or vulnerable components against a database of over 73,000 documented WordPress vulnerabilities. Run WPScan against your site and address any flagged items before moving on.

For e-commerce sites, sites handling regulated data, or high-traffic properties, a professional penetration test provides deeper assurance than automated scanning alone. Annual penetration testing is a reasonable baseline for most operations. PCI DSS compliance requires it at minimum annually and after significant changes.

Check your monitoring and update pipeline

  1. Go to Tools > Site Health in wp-admin and confirm there are no errors related to WordPress Cron. Broken Cron tasks silently disable automatic updates.
  2. Check the Google Safe Browsing Transparency Report for your domain to confirm your site is not flagged.
  3. Review the Security Issues tab in Google Search Console.
  4. Confirm your WAF logs are populating and that alerts are reaching your inbox.
  5. Subscribe to vulnerability feeds from WPScan, Patchstack, or Wordfence Intelligence so you receive early warning when a plugin you use is affected.

Security is not a one-time configuration. The official WordPress developer documentation treats brute-force defense, access control, and monitoring as ongoing practices rather than setup tasks. Review your audit logs for failed logins, admin actions, and file modifications on a regular schedule. Treat any anomaly as worth investigating rather than ignoring.

If you manage multiple WordPress sites and want to reduce the time spent on security alongside SEO, WordPress SEO automation tools like the WP SEO Agent run continuous technical audits across your sites from within the WordPress dashboard, surfacing issues that affect both security posture and search visibility before they become problems.

This content was generated with the help of AI and it may contain mistakes

Your customers are asking AI. Are you part of the answer?

In a quick demo, we show how WP SEO AI tracks your AI visibility, finds content gaps, and helps your website appear in ChatGPT, Google AI Overviews and more.

Dive deeper in