14+ years building on WordPress / Replies in under 5 hours
WordPress 9 min read · Updated July 2026

Secure Your WordPress Website: Essential Tips and Best Practices

Photo of Ajay Khandal
Ajay Khandal
WordPress Developer
TL;DR

Ten steps to harden a WordPress site against the most common attacks: (1) **Keep everything updated** — WordPress core (enable `WP_AUTO_UPDATE_CORE`), plugins, themes, and PHP (8.2+ required; PHP 7.4 is end-of-life). (2) **Enforce strong passwords** — password manager-generated, 20+ chars; use Password Policy Manager plugin to enforce site-wide. (3) **Enable 2FA** — WP 2FA plugin (TOTP) or Wordfence's built-in 2FA; mandatory for admin/editor roles. (4) **Limit login attempts + change login URL** — Limit Login Attempts Reloaded (3–5 attempts before lockout); WPS Hide Login to move `/wp-login.php` to a custom path. (5) **Install a security plugin** — Wordfence (WAF + malware scanner, 30-day delay on free tier), Sucuri (DNS-level proxy firewall, better for DDoS), or Solid Security (hardening checklist). (6) **Force HTTPS** — `define('FORCE_SSL_ADMIN', true)` in wp-config.php; 301 redirect in .htaccess; check with SSL Labs. (7) **Harden wp-config.php** — block direct access via .htaccess; set file perms to 400; regenerate security keys. (8) **Disable XML-RPC** — block in .htaccess or `add_filter('xmlrpc_enabled', '__return_false')` unless Jetpack is active. (9) **Back up with UpdraftPlus** — daily backups to offsite storage (S3/Drive/B2); retain 30 days daily + 3 months weekly; test restores quarterly. (10) **Monitor** — WP Activity Log for audit trail; Wordfence file integrity monitoring; UptimeRobot every 5 min; Google Search Console verified for malware alerts.

WordPress powers roughly 43% of the web, which makes it the most targeted CMS by automated attack bots. Most WordPress hacks aren’t the result of sophisticated zero-day exploits — they come from outdated plugins, weak admin passwords, and misconfigured servers. The good news is that the same things that make WordPress vulnerable are almost entirely within your control.

This guide covers ten concrete steps you can take right now to harden your WordPress installation against the most common attack vectors. Before any of this: if you’re still in the planning stage, the five decisions to make before building a WordPress site covers hosting environment choices that affect your security posture from day one.

Step 1: Keep WordPress core, themes, and plugins updated

Outdated software is the leading cause of WordPress compromises. The WordPress security team discloses and patches vulnerabilities quickly — but that patch only protects you once it’s installed. The typical attack window between a public vulnerability disclosure and mass exploitation is under 48 hours.

What to update, and how:

  • WordPress core: Enable automatic minor-version updates in wp-config.php:
    define('WP_AUTO_UPDATE_CORE', true);
    Major versions (6.x → 7.x) should be tested on staging first before updating production.
  • Plugins and themes: Enable auto-updates per-plugin in wp-admin → Plugins. For plugins where you need to vet changes first, set a weekly review reminder instead.
  • PHP version: Running PHP 7.4 or earlier is a significant risk — PHP 7.4 reached end-of-life in November 2022 and no longer receives security patches. Check your PHP version in wp-admin → Site Health → Info. PHP 8.2 or 8.3 is the current supported range.
  • Abandoned plugins: In wp-admin → Plugins, check the “Last Updated” date. A plugin with no updates in 2+ years and no active support forum is a liability — look for an actively maintained alternative.

Step 2: Enforce strong passwords across all user accounts

WordPress’s default password strength indicator suggests strong passwords but doesn’t enforce them. Any admin or editor account with a weak password is an entry point.

  • Admin accounts: Use a password manager (Bitwarden, 1Password) to generate 20+ character random passwords. Never reuse passwords across sites.
  • Enforce site-wide: The Password Policy Manager plugin (free) lets you set minimum length, required character types, and expiry periods for all user roles.
  • Check for exposed credentials: The Have I Been Pwned API is integrated into some security plugins — it flags if any site account email has appeared in known data breaches.
  • Remove unused accounts: Every admin account that isn’t actively used is an unnecessary attack surface. Delete old contributor, author, or admin accounts that are no longer needed.

Step 3: Enable two-factor authentication

Two-factor authentication (2FA) prevents an attacker from logging in even if they have a valid username and password. It’s the highest-ROI security addition for most WordPress sites because it neutralises credential-stuffing attacks entirely.

The two most common implementations:

  • WP 2FA plugin (free, wordpress.org): Adds TOTP-based 2FA (Google Authenticator, Authy) and email OTP. Lets you enforce 2FA for specific roles (you can require it for admins and editors but make it optional for subscribers).
  • Wordfence built-in 2FA: If you’re already running Wordfence, it includes 2FA without a separate plugin — enables TOTP + reCAPTCHA on the login form.

Configure 2FA to be mandatory for admin and editor roles. Subscribers and customers don’t need it unless the site handles sensitive user data (e-commerce, membership).

Step 4: Limit login attempts and change the login URL

WordPress’s default login page at /wp-login.php and /wp-admin/ receives constant brute-force traffic. Two quick measures cut this significantly:

Limit login attempts: Install Limit Login Attempts Reloaded (free). Set lockout after 3–5 failed attempts, with increasing lockout duration for repeat offenders. Block IP ranges that show repeated failed attempts.

Change the login URL: WPS Hide Login (free) changes /wp-login.php to a custom URL of your choice (e.g. /enter or /site-login). This won’t stop a determined attacker who knows the plugin, but it eliminates the large volume of automated bots targeting the default path. Store the new URL somewhere secure — if you forget it, you’ll need FTP/server access to deactivate the plugin.

Step 5: Install and configure a security plugin

A dedicated security plugin provides firewall protection, malware scanning, file integrity monitoring, and security hardening — all from a single dashboard. The three main options in 2026:

  • Wordfence: The most widely used WordPress security plugin. The free version includes a web application firewall (WAF), malware scanner, login security, and live traffic monitoring. Wordfence’s threat intelligence is updated in real-time for paid users and with a 30-day delay for free users — meaning free-tier users get patches for known threats 30 days after release.
  • Sucuri Security: Stronger at server-level protection and DDoS mitigation. Sucuri’s website firewall is a DNS-level proxy (like Cloudflare) that filters traffic before it reaches your server. More effective than a plugin-level firewall for high-traffic sites, but requires DNS changes.
  • Solid Security (formerly iThemes Security): Better for sites that want a one-stop security hardening checklist — file permission fixes, database prefix changes, XML-RPC management, and user account security in a single plugin.

For a detailed comparison of what each plugin actually catches and misses, the WordPress security plugins comparison for 2026 covers Wordfence vs Sucuri vs Solid Security vs MalCare with feature-by-feature breakdowns.

Step 6: Force HTTPS and check your SSL configuration

If your site isn’t running on HTTPS, every login, form submission, and authenticated request is transmitted in plaintext. Most hosts provide free SSL certificates via Let’s Encrypt — there’s no excuse for HTTP in 2026.

Once you have an SSL certificate installed, force HTTPS everywhere:

// Add to wp-config.php:
define('FORCE_SSL_ADMIN', true);

// Add to .htaccess (Apache):
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Also check:

  • HTTP Strict Transport Security (HSTS) header — tells browsers to always use HTTPS for your domain, even if someone types the HTTP URL
  • SSL Labs (ssllabs.com/ssltest) gives your SSL configuration an A–F grade and flags weak cipher suites or mixed content issues
  • WordPress Address URL and Site URL in wp-admin → Settings → General should both start with https://

Step 7: Harden wp-config.php and file permissions

wp-config.php contains your database credentials and security keys — it should never be web-accessible. Add this to your .htaccess to block direct access:

<files wp-config.php>
order allow,deny
deny from all
</files>

Recommended file permissions for a WordPress installation:

  • wp-config.php: 400 (owner read-only) or 440
  • .htaccess: 644
  • WordPress directories (wp-content/, wp-includes/): 755
  • WordPress files: 644

Set permissions via SSH:

find /path/to/wordpress -type d -exec chmod 755 {} \;
find /path/to/wordpress -type f -exec chmod 644 {} \;
chmod 400 wp-config.php

Also add security keys to wp-config.php if they’re missing or outdated — generate fresh ones at api.wordpress.org/secret-key/1.1/salt/. Regenerating keys immediately invalidates all active sessions, which is useful after a suspected compromise.

Step 8: Disable XML-RPC if you don’t need it

XML-RPC is a legacy remote publishing protocol that WordPress keeps enabled by default. It’s been obsolete since the REST API shipped in WordPress 4.7, but it remains a common attack vector because it allows an attacker to attempt thousands of username/password combinations in a single HTTP request — bypassing normal login attempt limits.

Disable it in .htaccess:

<files xmlrpc.php>
order allow,deny
deny from all
</files>

Or via a filter in your theme’s functions.php:

add_filter('xmlrpc_enabled', '__return_false');

When to keep it on: Jetpack requires XML-RPC for some of its features. The Jetpack app and some older mobile publishing workflows also rely on it. If you’re not using any of these, disable it.

Step 9: Back up your site regularly and test the restores

A backup you’ve never tested restoring is not a real backup — it’s a hope. WordPress security incidents often go undetected for weeks, which means you need multiple restore points, not just yesterday’s backup.

A solid backup strategy:

  • UpdraftPlus (free) or BackupBuddy (paid): automated scheduled backups of files + database
  • Offsite storage: Send backups to Google Drive, S3, Backblaze B2, or Dropbox — never store them only on the same server you’re backing up
  • Retention policy: Keep daily backups for 30 days, weekly backups for 3 months — this gives you a pre-infection restore point even for slow-moving compromises
  • Test restores: Restore to a staging environment quarterly to confirm the backup is valid and you know the steps

The complete WordPress maintenance guide covers backup schedules, plugin configuration, and what to do when you need to restore — including the steps for handling a compromised site.

Step 10: Monitor your site with security logs and uptime alerts

Most WordPress sites run unmonitored — owners don’t know their site has been compromised until a visitor reports it or Google shows a “this site may be hacked” warning in search results. Proactive monitoring catches incidents early:

  • Security audit log: WP Activity Log plugin records every admin action — user logins, plugin activations, post edits, settings changes. If someone does get in, you have a record of what they changed.
  • File integrity monitoring: Wordfence and Sucuri both monitor core WordPress files for unexpected changes. Any modification to a core file outside of an official update is a red flag.
  • Uptime monitoring: UptimeRobot (free for 50 monitors) pings your site every 5 minutes and emails you if it goes down. A sudden site outage can be the first sign of a security incident.
  • Google Search Console alerts: Google notifies verified Search Console users when it detects malware or manual actions on a site. Verify your site if you haven’t already.

The full approach to monitoring before a problem occurs — including what to do if you find an infected file — is in the proactive WordPress security measures guide.

Security is a process, not a one-time setup

Running through these steps once hardens your current setup, but WordPress security requires ongoing attention: plugins need updating when vulnerabilities are disclosed, passwords need rotating if accounts are involved in data breaches, and new attack vectors emerge regularly.

A practical cadence: weekly plugin updates, monthly review of user accounts and access logs, quarterly backup restore test, and immediate action whenever a high-severity CVE is disclosed for a plugin you’re running (the WPScan vulnerability database and Wordfence’s threat intelligence both publish CVE alerts you can subscribe to).

For the full picture on what a hardened WordPress site looks like day-to-day — including wp-admin access controls, server-level configurations, and security response playbooks — see the guides to essential WordPress security practices and securing WordPress against modern threats in 2026.

Frequently asked questions

Keeping WordPress core, themes, and plugins updated is the single highest-impact action. The majority of WordPress compromises exploit known vulnerabilities in outdated plugins or themes, and patches are typically available within days of disclosure. Enable automatic minor-version updates for WordPress core (`define('WP_AUTO_UPDATE_CORE', true)` in wp-config.php), enable auto-updates for plugins that don't need manual vetting, and check for abandoned plugins (no updates in 2+ years) that should be replaced. Combined with two-factor authentication on all admin accounts, these two measures eliminate the most common attack vectors.

It depends on where you need protection. Wordfence is a plugin-level web application firewall that runs on your server — it's effective for blocking known threats and provides malware scanning, login security, and live traffic monitoring. The free version's threat intelligence lags paid by 30 days. Sucuri's website firewall is a DNS-level proxy that filters all traffic before it reaches your server, making it more effective against DDoS attacks and volumetric threats. Sucuri is the better choice for high-traffic sites or sites that have been targeted before; Wordfence free is adequate for most standard WordPress sites. For a full feature comparison, see the WordPress security plugins comparison guide.

Yes, in most cases. XML-RPC is a legacy protocol that's been superseded by the WordPress REST API. It's a common attack target because it allows attackers to attempt thousands of login combinations in a single request, bypassing normal login lockout limits. Disable it by adding a deny rule in .htaccess (` order allow,deny / deny from all `) or using the filter `add_filter('xmlrpc_enabled', '__return_false')`. The exception: keep XML-RPC enabled if you use Jetpack (it requires XML-RPC for some features) or if you publish from the WordPress mobile app using a legacy configuration.

Daily database backups and weekly full-site backups (database + files) are the standard for most WordPress sites. E-commerce sites with daily orders should back up the database multiple times per day. Retention matters as much as frequency: keep daily backups for 30 days and weekly backups for 3 months — this gives you a clean restore point even if a compromise went undetected for several weeks. Store backups offsite (Google Drive, S3, Backblaze B2), never only on the same server. Crucially, test your restores quarterly on a staging environment — a backup you've never restored is a backup you don't know works.

WordPress has some baseline security: it hashes passwords using bcrypt, includes nonces for CSRF protection on forms and admin actions, sanitizes and validates input in core, and releases security patches quickly through its update system. What it doesn't include by default: a web application firewall, malware scanning, two-factor authentication, login attempt limiting, file integrity monitoring, or automatic blocking of malicious IPs. These all require plugins or server-level configuration. WordPress's security model assumes you'll keep it updated and supplement it with a security plugin — the baseline is a starting point, not a complete solution.

Partially. Without plugins you can: force HTTPS via .htaccess and wp-config.php, block direct access to wp-config.php and xmlrpc.php via .htaccess, set correct file permissions (755 for directories, 644 for files, 400 for wp-config.php), add security headers (X-Content-Type-Options, X-Frame-Options, Referrer-Policy) via .htaccess, disable directory listing, and disable the WordPress file editor via `define('DISALLOW_FILE_EDIT', true)`. What you can't do without plugins: enforce 2FA for admin users, get real-time malware scanning, monitor login attempts and block brute-force IPs, or get file integrity alerts. For anything beyond a basic static site, a security plugin like Wordfence or Solid Security covers the gaps that .htaccess rules can't.

Photo of Ajay Khandal

Written by Ajay Khandal

I'm a freelance WordPress developer with 14+ years of experience building, fixing, and speeding up sites for businesses, agencies, and store owners across the US, UK, Europe, and Australia. I specialize in custom themes, WooCommerce, and performance — the kind of work that shows up as faster load times and fewer support tickets. No account managers, no outsourced tickets — you work directly with me, with replies typically inside 5 hours.

Work with me →