A WordPress site gets compromised because one of four doors is left open: outdated software, weak logins, file permissions that let anyone write to your installation, or an unprotected admin interface. Securing it means closing all four in a specific order, starting with updates and access control before you touch firewall rules. A site that fails at the login layer cannot be rescued by a plugin at the network layer. The whole process takes most owners two to four hours the first time and roughly 30 minutes a month afterward, and none of it requires hiring a developer.
Update WordPress Core, Themes, and Plugins on a Fixed Schedule
WordPress publishes minor security releases automatically, but major version upgrades wait for you to click. Go to Dashboard β Updates and run everything pending at least once a week. The WordPress Security Team maintains a dedicated release cycle for patches like 6.8.2, and each one names the vulnerability it closes in the release announcement. Those announcements are the most useful security newsletter you'll ever subscribe to.
Set a schedule and stick to it. Weekly is the standard recommendation for plugins and themes; daily is fine for security releases flagged as critical. A common failure case: an owner updates everything at once on a live store, a plugin conflict white-screens the checkout page, and the site is down for four hours. Enable automatic minor core updates at Dashboard β Updates β Update Options, then test major versions on a staging copy first.
Delete anything you aren't using. Deactivated plugins still sit in your folder structure, and the WordPress plugin directory lists thousands of abandoned plugins that stopped receiving patches years ago. If a plugin hasn't been updated in twelve months, replace it. Each inactive extension is a file attackers can call directly.
Remember the version boundary: WordPress 5.2 and later ships with the Site Health screen, which flags abandoned plugins and insecure configurations. On older installs you won't see those warnings, so check plugin last-updated dates in the Plugins list yourself. Version 6.5, released March 2024, also introduced the Font Library, which matters for security only insofar as fewer plugins now need to load external assets.
Harden the Login Layer Before Anything Else
Every WordPress login has a predictable URL and a predictable username field. That's the whole reason brute-force attacks work. Install a login-limiting plugin such as Wordfence or Limit Login Attempts Reloaded and cap failures at five per IP per hour β Wordfence uses that default. Rename the login path if your host supports it, or use a plugin that lets you change the wp-login.php URL.
Turn on two-factor authentication for every administrator account. Badged under Users β Profile, most 2FA plugins support authenticator apps, email codes, and recovery codes. A strong password policy runs alongside it: 16 characters or more, no reuse across services, generated by a password manager. Password reuse is how credential-stuffing lists get into WordPress installs that otherwise look clean.
Consider locking the login down to your country or office IP via your firewall or a plugin's country-blocking rule. That single rule blocks most automated traffic from regions you never operate in, and it costs nothing. Keep a break-glass path open: if you set a geographic block and then travel, you'll lock yourself out unless you've whitelisted your own connection first.
The failure case that catches people: a 2FA plugin whose recovery email is the same mailbox that also receives password resets. If the mailbox is compromised, both factors fall. Use a separate recovery method β printed recovery codes stored offline work well.
Apply the Correct File Permissions on Your Host
Incorrect permissions are the quiet cause of many WordPress compromises, and hosts rarely fix them for you. On a typical Linux host, directories should be 755 and files 644, with wp-config.php at 600 or 640. Directories at 777 mean anyone on the server can write to your installation and inject a backdoor. Check via your host's file manager or SSH: find /path/to/site -type d -exec chmod 755 {} ; and the equivalent for 644 on files.
Ownership matters too. Files should belong to your hosting account's user, not to nobody or to root. If a support tech chowned everything to accept plugin uploads, you've handed the web server write access to your PHP files. Ask your host for the correct ownership and apply it with chown.
Disable file editing from the dashboard by adding define('DISALLOW_FILE_EDIT', true); to wp-config.php. That single line stops an attacker who already has admin access from editing theme PHP from inside the dashboard. It's not a substitute for locking login down, but it removes an easy persistence mechanism.
A specific edge case: managed hosts sometimes run the web server as a different user from your SFTP account. Setting permissions changes nothing until you confirm which user the PHP process runs as. Ask the host to state it in writing before you start chmod-ing.
Add a Web Application Firewall and Understand What It Catches
A WAF sits in front of your site and filters requests before they reach WordPress. Two plausible choices: a cloud WAF like Cloudflare's free tier, which proxies traffic and includes basic managed rules, or a plugin WAF like Wordfence or Sucuri's scanner, which maintains a signature list inside your install. The cloud option absorbs volumetric attacks before they touch your server; the plugin option sees application-level behavior that a proxy can't inspect.
| Option | Cost basis | Where filtering happens | Main limitation |
|---|---|---|---|
| Cloudflare WAF (free tier) | No charge for the basic managed ruleset | Edge proxy, before your host | Limited custom rule capacity on free plans; confirm current limits on Cloudflare's pricing page |
| Wordfence (free plugin) | No charge for core firewall | Inside the WordPress install | Cannot protect against traffic that overwhelms the server itself |
| Managed host WAF | Bundled in hosting plan | Host network layer | Coverage varies by host; ask for the rule set in writing |
Set the firewall to blocking mode rather than learning mode after a week of observation. Learning mode only logs; attackers get through. If your host provides its own WAF, don't stack three competing rule sets β two firewalls can produce false positives that block legitimate customers during checkout.
Watch for the classic false positive: a plugin that sends POST requests to admin-ajax.php can trip generic SQL-injection signatures. Whitelist the specific endpoint rather than disabling the rule, or you've removed protection across the whole site to fix one form.
Force HTTPS and Fix Mixed Content
HTTPS encrypts credentials in transit, and without it every login form submits a password in plain text across the network. Get a certificate β Let's Encrypt issues them free and most hosts auto-renew β install it, then redirect all HTTP traffic to HTTPS at the server level. In Apache that's a RewriteRule in .htaccess; in Nginx it's a return 301 in the server block. WordPress's Site URL and Home URL under Settings β General must both read https:// or the dashboard will keep generating http links.
Mixed content is the recurring failure. After the redirect, images, scripts, or fonts still loading over http will trigger browser warnings and can break checkout flows. The Really Simple SSL plugin fixes the database entries in bulk, or you can run a search-replace with WP-CLI: wp search-replace 'http://example.com' 'https://example.com'. Back up the database first β search-replace without a backup has ruined more sites than any hacker.
Add HTTP Strict Transport Security once HTTPS is stable, but only after you're certain every subdomain works over TLS. The header tells browsers to refuse plain HTTP for a set period; a premature long max-age can brick subdomains that still run on http.
Check your certificate expiry in your monitoring tool. Let's Encrypt certificates last 90 days, and auto-renewal failures are common after a host migration when the renewal cron no longer fires. A one-line uptime check against your domain will catch an expired cert before customers do.
Back Up Off-Site and Prove the Restore Works
A backup that lives on the same server as the site is not a backup; it's a copy that dies with the patient. Use a plugin such as UpdraftPlus or your host's snapshot tool, and send the archive to remote storage β S3, Google Drive, Dropbox, or a second host. Schedule daily database backups and weekly full-site backups at minimum; a store taking orders should back up more often.
Test the restore at least once per quarter. Restore to a staging environment, confirm the site loads and the database matches, then delete the staging copy. Untested backups routinely turn out to be incomplete β a database dump missing the wp_options table restores to a broken site.
Keep at least three generations: today, last week, last month. Ransomware and wiper attacks have hit WordPress sites; having a month-old clean copy is the difference between a bad afternoon and a lost business.
Encrypt backups at rest and store the encryption key separately from the archive. A backup sitting in a public S3 bucket is a data breach waiting to happen β a documented pattern in cloud storage misconfiguration reports.
Configure Security Headers Without Breaking the Site
Security headers are instructions your server sends with every response telling browsers what to refuse. The core set: Content-Security-Policy, X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN or DENY, Referrer-Policy: strict-origin-when-cross-origin, and Permissions-Policy restricting camera and microphone access. Most hosts let you add them in the server config or a plugin like Headers Security Advanced.
Content-Security-Policy is the one that breaks sites. Blocking inline scripts will kill Google Analytics, chat widgets, and some page builders until you whitelist their domains. Roll it out in report-only mode first (Content-Security-Policy-Report-Only), collect violations for a week, then enforce.
X-Frame-Options stops clickjacking β an attacker embedding your login page in an invisible iframe over a decoy. SAMEORIGIN permits framing only from your own domain, which suits most sites. DENY is stricter and blocks all framing, including legitimate embeds.
Verify headers with your browser's developer tools under the Network tab, or a header-checking service. A header added in .htaccess may be silently stripped by a proxy in front of your host, so confirm what the client actually receives, not what the config file says.
Restrict User Roles and Audit Accounts Monthly
WordPress ships five roles, and the difference between Administrator and Editor is the difference between full site control and none. Give every user the minimum role their job requires: writers get Author, editors get Editor, and Administrator accounts should number one or two. A site with six admins has six paths to takeover.
Audit the Users list monthly. Look for accounts you don't recognize, accounts with admin role that shouldn't have it, and stale accounts belonging to former staff. Delete rather than deactivate former employees β a deactivated account still holds its username and can be reactivated.
Change the default administrator username if it's still "admin." Usernames are half of every credential, and generic ones make brute-forcing trivial. Create a new admin account with a unique name, log in with it, then delete the old one β WordPress reassigns posts automatically.
Enable email notifications for new user registrations and role changes if your theme or a plugin supports it. A silent admin account created at 3 a.m. is the single most reliable indicator of an active compromise, and nobody sees it without an alert.
Monitor, Scan, and Know Your Recovery Plan
Monitoring tells you when something changed that shouldn't have. Set up file-integrity monitoring β Wordfence and similar scanners hash core files and alert on modification β and enable uptime checks from an external service so you learn about downtime before customers do. Review the WordPress Site Health screen weekly; it flags debug mode left on, outdated PHP, and failed scheduled events.
Keep PHP current. WordPress 6.x officially supports PHP 8.1 and later, and running an end-of-life PHP version like 7.4 means you're on a runtime that no longer receives security fixes. Your host's control panel usually lets you switch PHP versions per site; confirm plugin compatibility on staging first.
Write a one-page incident plan now, while you're calm. It should state: who has hosting credentials, where the backups live, how to force a password reset for all users, and which contact at the host handles compromises. Practicing the reset sequence on a quiet afternoon costs twenty minutes; discovering it during an attack costs the weekend.
Finally, know the signs of a live compromise: unexpected admin accounts, traffic spikes to obscure PHP files, search results showing spam pages you never published, or a host suspension notice about outbound spam. If you see any of them, take the site offline and restore from a known-clean backup rather than trying to delete the injected code by hand.
FAQ
Does a security plugin alone make a WordPress site secure?
No. A plugin can catch known attack patterns, but it cannot fix a weak admin password, a 777 file permission, or an abandoned theme. Run updates, harden login, and fix permissions first; a firewall plugin is the layer that catches what slips past those, and it works better on a clean foundation.
What's the first thing to do if I suspect my WordPress site was hacked?
Change all passwords from a separate, known-clean device β hosting panel, database, and WordPress admin β then restore from your most recent clean backup rather than cleaning files by hand. Attackers commonly leave persistence in multiple places, and file-by-file cleanup misses scheduled tasks and modified core files.
How often should I change my WordPress admin password?
Change it on suspicion, not on a calendar. Modern guidance from NIST withdrew the old 90-day rotation advice because forced rotation produces weaker, predictable passwords. Use a 16-character generated password unique to your site, store it in a password manager, and change it immediately if the site is ever compromised or your manager is breached.
Will a WordPress firewall slow down my site?
Rules processed at the cloud edge add little measurable latency because the request still travels to your server afterward; filtering happens in parallel with routing. Plugin-based firewalls add processing inside PHP, so on shared hosting with limited resources the effect is more noticeable. Test load time before and after enabling, not after reading a marketing page.
Is managed WordPress hosting more secure than shared hosting?
It typically is, because the host handles core updates, server patching, WAF rules, and staging β but only if you verify what's included. Ask for the update policy in writing, whether staging exists, and whether daily off-site backups are bundled. A managed plan with stale plugins is no safer than a cheap plan with diligent updates.
Can I secure WordPress for free?
Yes, the core of it: automatic minor updates, strong passwords, 2FA via a free plugin, Let's Encrypt certificates, Cloudflare's free WAF tier, and off-site backups to a free cloud storage allowance cover most of the work. The paid pieces that add real value are managed WAF rules and monitoring services; neither is essential for a small brochure site with regular manual checks.
What should I do if my host suspends the site for malicious activity?
Contact the host's abuse or security team immediately and ask for the specific evidence β outbound spam logs, injected file paths, timestamps. Restore from a clean backup, then rotate every credential, because suspension usually means an attacker already had code execution. Don't restore the same backup twice without checking it for the same files.
How do I protect a WordPress site with multiple authors?
Enforce role minimums β one or two Administrators, everyone else Author or Editor β and require 2FA for all accounts regardless of role. Review the user list monthly and remove stale accounts entirely. If you accept guest posts, keep them in a Contributor role that cannot publish without review, which prevents spam content from going live unreviewed.