Avoiding WordPress Security Breaches: 12 Tips
Protect your WordPress site from hacks with 12 proven security tips. Learn vulnerability prevention, plugin audits, and best practices from HostWP's infrastructure team.
Key Takeaways
- Enable two-factor authentication, keep WordPress core/plugins updated, and use strong passwords to block 90% of common attacks
- Install a Web Application Firewall (WAF) and security plugin to detect malware before it spreads across your site
- Regular security audits, POPIA-compliant backups, and SFTP access controls prevent data breaches and legal liability in South Africa
WordPress powers over 43% of all websites globally, making it the #1 target for automated attacks. In South Africa, we see this firsthand at HostWP: nearly 60% of WordPress sites we audit lack even basic security hardening, leaving them vulnerable to brute-force login attempts, SQL injection, and malware uploads. The good news? Most breaches are preventable with systematic, low-cost controls.
In this guide, I'll walk you through 12 practical security measures that actually work. These aren't theoretical—they're based on real vulnerabilities I've patched across 500+ SA WordPress installations, from small Cape Town boutiques to Johannesburg agencies running e-commerce platforms. You'll learn what to implement first, why, and exactly how to test whether your defences are holding up.
In This Article
1. Strong Passwords & Access Control
Weak credentials are the entry point for 81% of WordPress hacks. A strong admin password should be 16+ characters, include uppercase, lowercase, numbers, and symbols—and never be reused across sites.
I recommend using a password manager like Bitwarden or 1Password to generate and store unique passwords per environment. Limit admin accounts to essential personnel only. At HostWP, we've seen countless Durban and Johannesburg agencies lose client sites because they shared a single "admin123" password across their entire portfolio. One contractor leaves, and the password lives on with their personal notes.
Beyond passwords, restrict admin access by IP address. If your team works from a fixed office (or a consistent home network), whitelist those IPs in your firewall. This single step blocks 99% of automated bot login attempts from random data centres worldwide. Also disable the default "admin" username—rename it or create a new privileged account and delete the original.
2. Enable Two-Factor Authentication (2FA)
Two-factor authentication adds a second verification layer, so stolen passwords alone won't grant access. Even if a hacker guesses your password, they can't log in without your phone or authenticator app.
The easiest method is time-based one-time password (TOTP) using Google Authenticator, Microsoft Authenticator, or Authy. Install a plugin like Wordfence Security or Two Factor and require 2FA for all admin and editor accounts. Test it yourself: log out, try logging in from an incognito browser, and confirm the code prompt appears.
Asif, Head of Infrastructure at HostWP: "In 2023, we audited 187 South African WordPress sites and found zero instances of 2FA enabled by default. Within three months of enforcement, account compromise attempts dropped by 96%. It's the single highest ROI security measure I've seen—costs nothing, takes 10 minutes, and stops most attacks cold."
3. Keep WordPress Core Updated Religiously
WordPress releases security patches every 2–4 weeks. Delaying updates leaves known vulnerabilities open for exploitation. Hackers scan for outdated versions using automated tools—it's passive income for them.
Enable automatic background updates in wp-config.php or your hosting dashboard. At HostWP, all managed WordPress plans include automatic core and plugin patching, tested in a staging environment before going live. This removes human error and weekend emergencies.
On your own server, add this line to wp-config.php: define('WP_AUTO_UPDATE_CORE', true); Also enable automatic plugin updates for security releases only, and monitor plugin changelogs monthly. Many South African competitors like Xneelo and WebAfrica offer one-click staging—use it before updating production.
4. Audit & Remove Unused Plugins Ruthlessly
Every plugin is a potential attack vector. We've found WordPress sites in Pretoria running 40+ plugins, half of which haven't been updated in two years. Each inactive plugin is unpatched code sitting in your database.
Run an audit: list every active plugin, check its update status on wordpress.org, and verify the last update date. Delete anything unused, abandoned (no updates in 12+ months), or from untrusted developers. Download the HostWP security audit checklist to systematize this.
Specifically, avoid:
- Plugins with fewer than 1,000 active installations
- Plugins where support threads show unresponded complaints
- Plugins from developers with 1-star reviews
- Any plugin offering "SEO magic" or "instant traffic"—these are often malware-laden
At HostWP, we've quarantined over 150 compromised plugins used by SA clients. One particularly nasty malware, discovered in a fake "WP Speed Master" plugin, was injecting crypto-mining scripts into every page view. The site owner lost R15,000 in wasted bandwidth before we caught it.
Unsure which of your plugins are risky? Our team offers free WordPress security audits with a detailed risk assessment and remediation roadmap—typically completed within 48 hours for SA sites.
5. Deploy a Web Application Firewall (WAF)
A WAF sits between your visitors and your server, filtering malicious traffic before it reaches WordPress. It blocks SQL injection, cross-site scripting (XSS), brute-force login attempts, and DDoS floods in real-time.
Cloudflare is included free with all HostWP plans—we provision it automatically, configured with rules specifically for WordPress. Cloudflare's WAF catches 99.2% of attack patterns without blocking legitimate traffic. Other options: Sucuri (premium, ~R250/month) or Wordfence (plugin-based, ~R350/month).
To test your WAF is working: attempt a fake attack from your own IP. In Cloudflare's dashboard, create a test rule that blocks requests containing "?id=1' OR '1'='1" (a classic SQL injection). Then try visiting yoursite.com/?id=1' OR '1'='1 from a browser. If you see a Cloudflare block page instead of your site, the WAF is live.
6. Enforce Daily Automated Backups with POPIA Compliance
You can't prevent every breach, but you can recover from one in hours instead of months if you have clean backups. South Africa's POPIA (Protection of Personal Information Act) requires that any site collecting customer data maintain regular, tested backups. Failure to restore after a breach can mean fines up to R10 million.
Use a backup plugin like UpdraftPlus or BackWPup, configured to store encrypted backups in a remote location (AWS S3, Google Drive, or Dropbox). Daily backups are minimum; hourly is better for transactional sites. Critically, test a restore quarterly—a backup you've never restored from is useless.
At HostWP, we handle this automatically: daily backups, 30-day retention, encrypted storage in our Johannesburg data centre, and one-click restoration. Most clients sleep better knowing this is not their responsibility. Load shedding in South Africa makes this especially valuable—our backups continue uninterrupted even during Stage 6 cuts, because we operate on redundant UPS + generator power.
7. Install Real-Time Security Monitoring & Alerting
Passive backups help you recover, but active monitoring catches attacks while they're happening. Install Wordfence, Sucuri, or iThemes Security to receive instant alerts when suspicious activity is detected: unusual login attempts, file modifications, malware signatures, or brute-force patterns.
Configure alerts to email your phone. Most breaches go unnoticed for 200+ days; early detection can limit damage to hours. Set these thresholds: alert after 5 failed login attempts in 10 minutes, after any file upload to /uploads with a .php extension, and after login from an unusual country (unless your team is traveling).
8. Secure Your Database Access
Your WordPress database contains every post, page, user, and customer record. Weak database credentials are a disaster waiting to happen. Change the default database user from "wp_user" to something unguessable, use a 20+ character password, and limit database access to your web server's IP only.
If you're running your own server, disable remote database connections. Change the default database port from 3306 to a non-standard port (e.g., 3307), and run SHOW GRANTS FOR 'wp_user'@'localhost'; to ensure the user has only SELECT, INSERT, UPDATE, DELETE permissions—never CREATE, DROP, or ALTER.
9. Lock Down File & Directory Permissions
WordPress files should be readable but not writable by the web server. Set /wp-content to 755, /wp-admin and /wp-includes to 755, all .php files to 644, and wp-config.php to 600. This prevents attackers from uploading or modifying core files even if they gain partial access.
Use SFTP (Secure File Transfer Protocol) only—never FTP, which transmits credentials in plaintext. Most hosting providers, including HostWP, disable FTP entirely and provide SFTP with key-based authentication. In your hosting control panel, create an SFTP user with a non-standard username and strong password, then remove or disable it when contractors finish their work.
10. Disable Dangerous Features & File Editing
WordPress allows administrators to edit plugin code via the dashboard (Plugins → Plugin File Editor). This is convenient but dangerous: if a hacker gains admin access, they can inject malware into active plugins with one click. Disable this immediately by adding to wp-config.php: define('DISALLOW_FILE_EDIT', true);
Also disable file uploads for untrusted roles. Authors and contributors should not upload plugins or themes—only administrators should. Go to Settings → Media and disable all uploads for contributor/author roles if your site doesn't require them.
11. Enforce HTTPS & Secure Cookies
HTTPS encrypts traffic between your visitor's browser and your server, preventing man-in-the-middle attacks on public WiFi. All HostWP plans include free SSL certificates via Let's Encrypt, auto-renewed annually. If you're managing SSL yourself, redirect all HTTP traffic to HTTPS via .htaccess:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Also add this to wp-config.php to force HTTPS for admin logins and cookies: define('FORCE_SSL_ADMIN', true); and define('FORCE_SSL_LOGIN', true); Then in the WordPress dashboard, go to Settings → General and change both site URLs from http:// to https://.
12. Implement Security Headers & Content Security Policy
Security headers instruct browsers how to handle your site: prevent clickjacking, block inline scripts, and enforce HTTPS. Add these to your .htaccess or nginx config:
- X-Frame-Options: SAMEORIGIN — prevents your site being loaded in an iframe
- X-Content-Type-Options: nosniff — prevents MIME sniffing
- Strict-Transport-Security: max-age=31536000 — forces HTTPS for 1 year
- Content-Security-Policy: default-src 'self' — blocks inline JavaScript
Use an online header checker (securityheaders.com) to audit your current headers. Most WordPress sites score F or D—you can reach A+ in 20 minutes with a security plugin.
Frequently Asked Questions
Q: How do I know if my WordPress site has been hacked?
A: Look for: unexpected admin accounts, sudden traffic spikes, malware warnings from Cloudflare/Google Search Console, defaced pages, or slow performance. Run Wordfence's malware scan (free), check wp-admin → Users for unknown accounts, and review wp-content/uploads for suspicious .php files. If you find evidence, immediately change all passwords, enable 2FA, and restore from a clean backup dated before the breach.
Q: What's the cost of a WordPress security breach in South Africa?
A: Direct costs (recovery, cleanup, legal) average R50,000–R500,000. Indirect costs are worse: lost traffic, damaged reputation, POPIA fines (up to R10M for data breaches), and customer lawsuits. One Cape Town e-commerce site we recovered had lost R200,000 in sales during the two weeks their site was defaced. Invest R2,000–R5,000 yearly in security infrastructure; it's insurance you'll never regret.
Q: Should I disable WordPress REST API for security?
A: Not completely—many plugins and themes need it. Instead, restrict REST API access: disable it for unauthenticated users via a plugin (REST API Toolbox), or require authentication. Monitor API access logs for unusual patterns (excessive requests from bots). Most breaches don't exploit REST API, so this is a lower priority than password hardening and updates.
Q: How often should I audit my WordPress security?
A: Quarterly at minimum. Check plugin updates, review user accounts for dormant/unauthorized access, audit file permissions, test backup restoration, and run a malware scan. If you're managing 10+ sites, automate this with a plugin like Wordfence (logs to a central dashboard) or hire a security auditor annually. HostWP clients get free quarterly audits included in support.
Q: Is LiteSpeed Web Server more secure than Apache or Nginx?
A: LiteSpeed, Apache, and Nginx are equally secure if properly configured. LiteSpeed's advantage is performance (faster response times = fewer timeouts) and built-in DDoS protection. At HostWP, we use LiteSpeed on all plans because it blocks common attacks (slowloris, HTTP floods) at the web server level before they even reach WordPress. But security ultimately depends on updates, firewalls, and file permissions—the server type matters less than the operator's diligence.