
Article Guide
Use these jump points to move through the article faster.
WordPress is the most popular CMS in the world. It powers over 40% of all websites — which makes it, by extension, the most targeted CMS in the world for hackers, bots, and malware campaigns. That’s not a reason to switch platforms. But it is a reason to take site security seriously rather than treating it as an afterthought.
The reality is that most WordPress sites that get hacked aren’t victims of sophisticated attacks. They’re victims of preventable ones: outdated plugins, weak passwords, exposed admin panels, default file permissions, and zero monitoring. A motivated attacker doesn’t need to write custom exploit code when they can scan millions of WordPress sites per day for known vulnerabilities and hit the ones that haven’t patched a three-year-old plugin.
This guide is a practical security hardening reference for WordPress site owners, developers, and agencies. We’ll go through every major attack surface — from login security and file permissions to database protection, SSL, admin hardening, and automated monitoring — and give you concrete actions for each one.
You don’t need to be a security expert to implement most of this. You need a methodical approach and the right tools.
Why WordPress Sites Get Hacked: Understanding the Attack Surface
Before diving into fixes, it’s worth understanding how WordPress sites typically get compromised. There are five main attack vectors:
1. Outdated plugins and themes This is the leading cause of WordPress compromises. Plugins and themes with known vulnerabilities — CVEs that have been publicly disclosed and patched — remain exploitable on sites that haven’t updated. Attackers automate scans to find sites running vulnerable versions and exploit them at scale.
2. Weak or compromised credentials Brute force attacks — automated tools cycling through millions of username/password combinations — target the WordPress login page. Default usernames like “admin” combined with weak passwords make this trivially easy. Credential stuffing (using leaked username/password pairs from other breached sites) is also common.
3. Null and pirated themes/plugins Downloading “nulled” (cracked) premium plugins or themes from unofficial sources is one of the fastest ways to install malware. These redistributed files frequently contain backdoors, encrypted malware, or phishing scripts hidden in code that looks legitimate.
4. Insecure hosting environments Shared hosting environments where other sites on the same server are compromised can lead to cross-site contamination. Hosting providers with poor security configurations, no malware scanning, and inadequate account isolation increase risk for everyone on the server.
5. Exposed configuration files and file permissions Incorrect file and directory permissions can expose sensitive files like wp-config.php to unauthorized access. Some misconfigurations allow directory browsing, making it trivial to map a site’s file structure and find vulnerable components.
Understanding these vectors tells you exactly where to focus your hardening effort.
Part 1: Keep Everything Updated — Your First Line of Defense
This sounds obvious. It’s also the most consistently ignored advice in WordPress security. Let’s make it concrete.
WordPress Core Updates
WordPress releases major updates several times per year and minor security updates as needed. Minor security updates (like 6.4.1 → 6.4.2) should be applied immediately — they patch specific vulnerabilities, often publicly disclosed CVEs.
WordPress supports automatic background updates for minor releases. This should be enabled on every production site unless there’s a specific reason not to:
<span class="token token">// In wp-config.php — enable automatic minor updates</span>
<span class="token token">define</span><span class="token token">(</span><span class="token token single-quoted-string">'WP_AUTO_UPDATE_CORE'</span><span class="token token">,</span> <span class="token token single-quoted-string">'minor'</span><span class="token token">)</span><span class="token token">;</span>For major updates (6.x to 7.x), test in staging before updating production. Major updates sometimes have compatibility breaks with plugins or themes.
Plugin Updates: The Highest Risk Surface
Plugins represent the largest security risk simply because there are so many of them. The average WordPress site runs between 15 and 25 plugins. Each one is a potential vulnerability surface. When a security researcher finds an exploit in a popular plugin, the window between disclosure and patch deployment is critical — sites that haven’t updated within days can be compromised.
Establish a weekly update practice:
- Log into WordPress admin
- Go to Dashboard → Updates
- Review available plugin and theme updates
- Check changelogs for security-related entries
- Update, then do a quick site check for any visual or functional regressions
For production sites with no staging environment, consider using a plugin that creates a checkpoint before updating so you can roll back if an update breaks something.
Theme Updates
Themes are a frequently overlooked update surface. Even if you’re using a child theme, the parent theme can have vulnerabilities. Update themes on the same schedule as plugins.
If you’re using a theme from a commercial marketplace (Themeforest, etc.) that hasn’t been updated in over a year, treat it as a risk signal. Abandoned themes don’t receive security patches.
Remove Unused Plugins and Themes
Every inactive plugin and theme still represents a vulnerability surface if it’s installed — even if deactivated. Deactivated plugins still have their files on your server. If those files contain vulnerabilities, they can be exploited regardless of activation status.
Audit your plugins and themes regularly. Delete anything you’re not actively using. Keep your active plugin count as lean as possible — every plugin you remove is an attack surface you eliminate.
Part 2: Login Security — Protecting Your Admin Panel Access
The WordPress login page at and is a magnet for automated attacks. Protecting it is one of the highest-impact security improvements you can make.
Change the Default Admin Username
If your WordPress administrator account is named “admin,” “administrator,” or your domain name — change it immediately. These are the first usernames every brute force tool tries.
WordPress doesn’t allow username changes through the admin UI, but you can:
- Create a new user with administrator role and a unique username
- Reassign all posts from the old admin to the new account
- Delete the old “admin” account
Use Strong, Unique Passwords
WordPress has a built-in password strength indicator. Use it. A strong WordPress admin password should be:
- At least 16 characters
- A mix of uppercase, lowercase, numbers, and symbols
- Not used on any other site
- Not based on guessable information (name, domain, date of birth)
Use a password manager (1Password, Bitwarden, etc.) so you never need to remember admin passwords. Just generate them strong and let the manager store them.
Enable Two-Factor Authentication (2FA)
Two-factor authentication adds a second verification step after password entry. Even if an attacker has your correct password through a data breach or phishing, they can’t log in without the second factor.
For WordPress, 2FA can be implemented via:
- TOTP authenticator apps (Google Authenticator, Authy) — generates time-based codes
- Email-based OTP — sends a code to your email address
- Hardware keys (YubiKey) — physical security key required for login
A security plugin with 2FA support, or a dedicated plugin like WP 2FA, handles this without custom code. Enable it on all administrator accounts at minimum — and ideally for all user accounts with elevated roles.
Limit Login Attempts
By default, WordPress allows unlimited login attempts. This makes brute force attacks trivial — automated tools can try thousands of passwords per minute until they find the right one.
Limit login attempts to something like 5 tries before a temporary lockout. Most security plugins handle this. After lockout, require either a waiting period or manual administrator action to restore access.
Change the Login URL
Moving your login page from the default to a custom URL doesn’t stop determined attackers, but it stops the enormous wave of automated bots that scan specifically for that filename. Many attack scripts simply skip sites where the default login URL doesn’t exist.
Use a plugin like WPS Hide Login or your security plugin’s URL change feature. Note: if you change your login URL, document it securely. Forgetting it can lock you out of your own admin.
Implement IP Allowlisting for Admin Access
If you and your team always access WordPress admin from consistent IP addresses (office, home network), you can restrict wp-admin access entirely to those IPs via .htaccess:
<Files wp-login.php>
Order Deny,Allow
Deny from All
Allow from 203.0.113.0 # Replace with your IP
Allow from 198.51.100.0 # Add additional IPs as needed
</Files>This is a powerful restriction — anyone not on the allowlist simply can’t reach the login page. It breaks access for users logging in from changing IP addresses (mobile networks, travel), so it’s most practical for single-admin or tightly controlled agency setups.
Set Up CAPTCHA on the Login Page
Adding a CAPTCHA challenge (reCAPTCHA v3, hCaptcha, or Cloudflare Turnstile) to your login form stops most automated bots cold. Modern invisible CAPTCHAs don’t add friction for real users but present an unsolvable barrier to bots. This pairs well with login attempt limiting for layered protection.
Part 3: File Permissions and Configuration Security
How your WordPress files and directories are configured at the server level has a significant impact on security. Incorrect permissions can expose sensitive files to unauthorized reads or give attackers write access they shouldn’t have.
Correct File and Directory Permissions
The recommended WordPress file permission structure:
- Directories: 755 (owner can read/write/execute; group and public can read/execute)
- Files: 644 (owner can read/write; group and public can read only)
- wp-config.php: 600 or 440 (owner can read/write; nobody else can access it)
- wp-admin/: 750 or 755 depending on your setup
You can set permissions via FTP (using a client like FileZilla), via cPanel file manager, or via SSH:
<span class="token token"># Set directories to 755</span>
<span class="token token">find</span> /path/to/wordpress/ -type d -exec <span class="token token">chmod</span> <span class="token token">755</span> <span class="token token">{</span><span class="token token">}</span> <span class="token token">\</span><span class="token token">;</span>
<span class="token token"># Set files to 644</span>
<span class="token token">find</span> /path/to/wordpress/ -type f -exec <span class="token token">chmod</span> <span class="token token">644</span> <span class="token token">{</span><span class="token token">}</span> <span class="token token">\</span><span class="token token">;</span>
<span class="token token"># Protect wp-config.php specifically</span>
<span class="token token">chmod</span> <span class="token token">600</span> /path/to/wordpress/wp-config.phpNever set directories to 777 (world-writable). This gives any process on the server — including malicious scripts — write access to your WordPress files.
Protect wp-config.php
The wp-config.php file contains your database credentials, secret keys, and other sensitive configuration. By default it’s in your WordPress root directory. Protect it:
Move it one level up: WordPress automatically looks in the parent directory if wp-config.php isn’t in the WordPress root. Moving it out of the web root means it can’t be served over HTTP at all.
Block direct access via .htaccess:
<files wp-config.php>
order allow,deny
deny from all
</files>Set correct permissions: chmod 600 ensures only the owner (the PHP process) can read the file.
Disable Directory Browsing
If directory listings are enabled on your server, anyone can browse your WordPress files at URLs like . This exposes your file structure, helps attackers identify plugin versions, and can expose private files.
Disable directory browsing in .htaccess by adding this to your WordPress root .htaccess file:
Options -IndexesThis returns a 403 Forbidden instead of a file listing for any directory without an index file.
Secure Your .htaccess File
The .htaccess file itself should be protected from being read directly via HTTP:
<Files .htaccess>
Order Allow,Deny
Deny from All
</Files>Place this within the .htaccess file itself — Apache processes the rules before determining whether to serve the file.
Part 4: Database Security
Your WordPress database contains everything — posts, user data, settings, passwords, and more. Protecting database access is foundational security.
Change the Database Table Prefix
By default, WordPress uses as the prefix for all database tables. SQL injection attacks targeting WordPress often look for specific table names like and . Using a custom prefix makes these attacks less straightforward.
If you’re setting up a new WordPress site, change the prefix during installation:
- Edit wp-config.php and change
to something like - The installer will use your custom prefix
For existing sites, changing the prefix is possible but involves more steps — a database search-and-replace as well as the prefix change. Do it in staging first.
Use a Dedicated Database User with Minimal Privileges
Your WordPress database user should have only the permissions it actually needs: SELECT, INSERT, UPDATE, and DELETE. It should NOT have DROP, CREATE, or ALTER table privileges unless you’re actively performing a migration or major update.
Create a dedicated database user in cPanel, phpMyAdmin, or your hosting panel, and grant only the necessary privileges. This limits the damage if the database credentials are ever compromised.
Disable Remote Database Access
Unless your WordPress setup requires it, your database should only accept connections from localhost — not from external IP addresses. Most shared hosting environments configure this correctly by default, but on VPS or dedicated servers, verify that MySQL isn’t listening on an external port unless you have a specific reason for it.
Part 5: SSL and HTTPS — Non-Negotiable in 2026
If your site is still on HTTP, it’s insecure by definition. All traffic between your server and visitors is unencrypted. Login credentials, form submissions, and sensitive data are transmitted in plaintext.
HTTPS encrypts all traffic using SSL/TLS certificates. Beyond security, HTTPS is a confirmed Google ranking signal. And browsers mark HTTP pages as “Not Secure” — which visibly undermines trust.
Getting and Installing SSL
Most hosting providers offer free SSL certificates via Let’s Encrypt. Many install it automatically or offer a one-click installation through their control panel. If your host doesn’t:
- Use Let’s Encrypt directly (certbot.eff.org) if you have server access
- Use Cloudflare’s free SSL if you route traffic through their CDN
- Purchase a commercial SSL certificate from a provider like DigiCert or Sectigo if you need extended validation (EV) certificates for business trust signals
Forcing HTTPS in WordPress
After SSL is installed, force HTTPS at multiple levels:
- Update WordPress settings: Settings → General → WordPress Address and Site Address — both should use
- Force HTTPS redirect in .htaccess:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]- Enable HSTS headers to prevent any downgrade
Check for mixed content (HTTP resources loading on HTTPS pages) using your browser’s developer tools or a tool like WhyNoPadlock.com. Mixed content breaks the security padlock and undermines HTTPS.
Part 6: WordPress Admin Security Hardening
Disable File Editing in WordPress Admin
WordPress has a built-in theme and plugin editor in the admin panel (Appearance → Theme File Editor). If an attacker gains admin access, this editor lets them inject malicious code directly into your theme files without needing FTP or server access.
Disable it by adding to wp-config.php:
<span class="token token">define</span><span class="token token">(</span><span class="token token single-quoted-string">'DISALLOW_FILE_EDIT'</span><span class="token token">,</span> <span class="token token">true</span><span class="token token">)</span><span class="token token">;</span>This removes the file editor from the admin menu entirely. Most sites have no reason to use it — edits should be made via FTP, staging environments, or version-controlled deployment.
Disable File Modifications Altogether
For even tighter security — especially for sites where themes and plugins are deployed via Git or CI/CD and shouldn’t be modifiable from the server — you can disable all file modifications:
<span class="token token">define</span><span class="token token">(</span><span class="token token single-quoted-string">'DISALLOW_FILE_MODS'</span><span class="token token">,</span> <span class="token token">true</span><span class="token token">)</span><span class="token token">;</span>This prevents installing and updating plugins and themes from within WordPress admin. Only use this if you have another deployment mechanism, because it also blocks WordPress core updates from the dashboard.
Limit User Roles and Permissions
Every WordPress user account should have the minimum role needed for their function:
- Subscriber — registered users who can only manage their own profile
- Contributor — can write posts but not publish
- Author — can publish their own posts
- Editor — can publish and manage all posts
- Administrator — full access
Never give administrator access to users who don’t need it. Audit user accounts regularly and remove accounts for former employees, clients, or freelancers immediately when the relationship ends.
Monitor Admin Activity
Admin activity logging gives you a record of who did what in your WordPress backend. This is invaluable for:
- Identifying unauthorized access after a breach
- Auditing content changes in multi-author environments
- Spotting compromised user accounts behaving strangely
A security plugin with activity logging records events like: user logins and logouts, plugin installs and updates, theme changes, content modifications, setting changes, and failed login attempts.
Disable XML-RPC If You Don’t Use It
WordPress includes an XML-RPC interface at . It was historically used for third-party app integrations. It’s also a significant attack vector — it allows brute force attacks that bypass login protection measures because it can process many authentication requests in a single HTTP call.
If you’re not using XML-RPC for Jetpack, mobile app publishing, or a specific integration, disable it completely:
# In .htaccess
<Files xmlrpc.php>
Order Deny,Allow
Deny from All
</Files>Or use a filter in your theme’s functions.php:
<span class="token token">add_filter</span><span class="token token">(</span><span class="token token single-quoted-string">'xmlrpc_enabled'</span><span class="token token">,</span> <span class="token token single-quoted-string">'__return_false'</span><span class="token token">)</span><span class="token token">;</span>Part 7: Security Monitoring and Malware Scanning
Hardening your site reduces the attack surface but doesn’t make breaches impossible. Monitoring detects problems when they happen so you can respond quickly.
Regular Malware Scanning
Malware on a WordPress site can be subtle. Backdoors, injected redirect code, SEO spam injection, and credential-harvesting scripts are often inserted in ways that don’t immediately break site functionality. The site keeps working; the attacker keeps benefiting.
Run automated malware scans using a security plugin. What a good scanner checks:
- Changed core WordPress files against known-good checksums
- Known malware signatures in plugin and theme files
- Suspicious code patterns (obfuscated base64-encoded strings, eval() calls on dynamic content)
- Injected code in database content (malicious scripts in posts or options)
- Backdoor scripts in unusual locations
Schedule malware scans at least weekly. Configure alerts so you get an email if anything suspicious is found.
Uptime Monitoring and Downtime Alerts
Hacked sites sometimes get suspended by hosting providers or have their pages replaced by defacement pages. An uptime monitor checks your site every few minutes and alerts you immediately if it goes down.
Free options include UptimeRobot (checks every 5 minutes, free tier). Paid options offer more frequent checks and better alert routing.
A site going down unexpectedly is often the first visible sign of a security incident. Knowing within minutes rather than hours makes a significant difference to response time.
Google Search Console Security Alerts
Google Search Console sends alerts when it detects security issues on your site — specifically when it finds malware that could harm visitors, or when your site has been manually flagged for distributing harmful software.
These alerts are sent to verified site owners via email and displayed in the Security Issues section of GSC. After remediating any found malware, you request a review through GSC to have the security warning removed from search results.
Backup: Your Security Safety Net
Backups aren’t a security measure in the preventive sense, but they’re your recovery mechanism when preventive measures fail. A recent backup means a security incident doesn’t mean permanent data loss.
Backup requirements for a secure WordPress setup:
- Daily automated backups for active sites
- Offsite storage — backups stored only on the same server as your site are lost if the server is compromised
- Database + files — both the database and all WordPress files need backing up
- Tested restoration process — an untested backup might fail when you need it most
Store backups in cloud storage (Amazon S3, Google Cloud Storage, Backblaze B2, Dropbox) separate from your hosting account. Most WordPress backup plugins support offsite backup destinations.
Part 8: WordPress Security Plugins
A dedicated security plugin handles many of the monitoring, scanning, and protection tasks outlined in this guide without requiring manual configuration of every element.
Key features to look for in a WordPress security plugin:
- Malware scanning with signature database updates
- Login protection (brute force limiting, 2FA support)
- File integrity monitoring
- Activity logging
- Firewall rules (WAF)
- Automatic threat blocking based on IP reputation
- Security notifications and reporting
WPMazic’s platform focuses on WordPress performance and SEO tools, but the WordPress security plugin ecosystem includes well-established dedicated options like Wordfence, Sucuri, and iThemes Security.
When choosing a security plugin, consider:
- Update frequency and active development — security requires constant database updates
- Server resource impact — some security plugins are notoriously heavy on shared hosting
- Whether it includes a firewall that runs before PHP (CDN-level WAFs are more efficient)
- Quality of incident response and support if you’re dealing with a live breach
Part 9: Web Application Firewall (WAF) — Blocking Attacks at the Edge
A Web Application Firewall filters malicious traffic before it reaches your WordPress application. This is fundamentally more effective than plugin-based security alone, which only activates after a request reaches your server.
Cloudflare WAF
Cloudflare is the most widely used CDN and WAF for WordPress sites. Even the free tier provides DDoS protection and basic bot filtering. The paid tiers add custom firewall rules, rate limiting, bot management, and the Cloudflare Managed Ruleset — a curated set of rules that blocks known attack patterns.
For most WordPress sites, Cloudflare’s Pro plan provides an excellent security layer at a manageable cost. Setting it up involves pointing your domain’s nameservers to Cloudflare (or using their partial proxy setup), which routes all traffic through their network before it hits your origin server.
Sucuri WAF
Sucuri’s website firewall is specifically designed for WordPress and routes traffic through their network. It includes virtual patching — blocking exploit attempts against vulnerable plugin versions even before you’ve updated the plugin itself.
Hosting-Level WAF
Some managed WordPress hosting providers (Kinsta, WP Engine, Flywheel) include server-level WAF rules as part of their hosting stack. If you’re on managed WordPress hosting, check what security measures are already included — you may have WAF protection without a separate service.
WordPress Security Hardening Checklist
Use this as an audit checklist for any WordPress site:
Updates
- WordPress core is updated to the latest version
- All plugins updated within the last 7 days
- All themes updated
- No unused plugins or themes installed
Login Security
- No accounts with username “admin” or “administrator”
- Strong, unique password on all admin accounts
- Two-factor authentication enabled for all administrators
- Login attempts limited (5 attempts before lockout)
- CAPTCHA on login page
- Login URL changed from default /wp-login.php
File and Server Security
- File permissions: directories 755, files 644, wp-config.php 600
- Directory browsing disabled (Options -Indexes)
- wp-config.php protected from HTTP access
- .htaccess protected from HTTP access
- File editor disabled in WordPress admin (DISALLOW_FILE_EDIT)
Database
- Custom database table prefix (not wp_)
- Database user has minimal required privileges only
- Remote database access disabled
SSL/HTTPS
- Valid SSL certificate installed and auto-renewing
- All traffic forced to HTTPS
- No mixed content warnings
- HSTS headers configured
Monitoring
- Malware scanner active and running weekly scans
- Uptime monitoring with instant alerts
- Activity log capturing admin actions
- Google Search Console verified and checked monthly
- Backup running daily with offsite storage
Advanced
- XML-RPC disabled (if not in use)
- WAF in place (Cloudflare, Sucuri, or hosting-level)
- User accounts audited — no orphaned accounts from old team members
Final Thoughts
WordPress security isn’t about achieving perfection — it’s about removing low-hanging fruit and making your site significantly harder to compromise than the average poorly-maintained installation. Attackers go for easy wins. A site with updated plugins, strong credentials, limited login access, monitored file integrity, and automated backups is far less attractive than the millions of sites that haven’t applied even basic hardening.
Work through this guide systematically. You don’t need to implement everything in a single session — start with the highest-impact items (updates, login security, SSL, backups) and build from there.
For agencies, creating a security checklist you run on every new client site — before doing SEO or any other work — pays dividends repeatedly. A hardened site doesn’t get hacked and rebuilt. It just keeps running.