Security

How to Secure Your WordPress Website

Rejaul Karim8 min read

WordPress powers a very large share of the web, which makes it a constant target. Attackers do not usually single out your site. They run automated tools that scan thousands of websites for outdated plugins, weak passwords and known vulnerabilities, and they strike whichever sites they can get into. The good news is that most hacked WordPress sites were compromised through problems that are easy to prevent. This guide gives you a practical, prioritised security plan that works for blogs, business sites and online shops.

Last reviewed: November 2026. Security advice evolves with new threats, so keep an eye on the official WordPress.org news and your security plugin's alerts.

Why WordPress sites get hacked

WordPress core is actively maintained and generally secure. The weak points are usually around it:

  • Vulnerable plugins and themes. Security researchers consistently find that the large majority of newly reported WordPress vulnerabilities are in plugins and themes rather than core.

  • Outdated software. Known bugs stay open on sites that do not update.

  • Weak or reused passwords, especially for admin accounts.

  • Pirated ("nulled") themes and plugins, which often include hidden backdoors.

  • Poor hosting or misconfiguration, such as bad file permissions and outdated PHP.

1. Keep everything updated

This is the single most important habit. Update WordPress core, every plugin and every theme as soon as updates are released, especially those marked as security fixes. WordPress installs minor security releases automatically by default, and you can switch on automatic updates for plugins and themes from the Plugins and Appearance > Themes screens. For a business-critical site, test updates on a staging copy first, or take a backup before updating. Make sure your server runs a currently supported PHP version, since old versions no longer receive security patches. Your host's control panel usually lets you change it.

2. Choose plugins and themes carefully

  • Download only from the official WordPress.org directory or from reputable commercial developers.

  • Never use nulled or cracked premium plugins. They are one of the most common sources of infections.

  • Check the number of active installations, the last update date, compatibility with your WordPress version and recent support activity.

  • Delete (not just deactivate) plugins and themes you do not use. Inactive code can still be exploited.

  • Prefer fewer, well-maintained plugins over many small ones.

3. Use strong passwords and two-factor authentication

Every user with admin or editor access should use a long, unique password stored in a password manager. Turn on two-factor authentication (2FA) with an authenticator app, using a plugin such as Wordfence, Solid Security or a dedicated 2FA plugin, and require it for administrators at least. Do not use "admin" as a username, and delete any accounts that are no longer needed.

4. Limit login attempts and protect the login page

Bots constantly try passwords on /wp-login.php. Counter them by limiting failed login attempts, which most security plugins can do, adding a CAPTCHA or a challenge from your CDN, and where possible restricting access to the admin area by IP address if your team has fixed addresses. Changing the login URL is only a minor deterrent, so do not rely on it alone.

5. Use HTTPS everywhere

Install an SSL certificate, and many hosts provide a free one through Let's Encrypt. Make sure the site redirects all traffic from http to https and that your site address in Settings > General uses https. Encryption protects logins and form data from being intercepted, and browsers warn visitors about insecure sites.

6. Back up regularly, and test the restore

No security measure is perfect, and a good backup turns a disaster into an inconvenience. Follow the 3-2-1 rule: keep three copies of your data, on two different types of storage, with one copy offsite. Use a plugin such as UpdraftPlus, Jetpack Backup or a backup service from your host, and store copies somewhere separate from the web server, such as cloud storage. Back up daily if the site changes often, and weekly otherwise. Most importantly, practise restoring a backup, because a backup you cannot restore is not a backup.

7. Install a reputable security plugin and a firewall

A security plugin adds malware scanning, file integrity checks, login protection and alerts. Well-known options include Wordfence, Solid Security (formerly iThemes Security), Sucuri and Patchstack, which focuses on vulnerability alerts. You only need one main security plugin, since running several that do the same job can cause conflicts and slow your site. For stronger protection, add a web application firewall (WAF), available through Cloudflare, Sucuri or your host, which blocks malicious requests before they reach WordPress.

8. Harden the configuration

These technical changes are quick and effective. Take a backup before editing any file.

  • Disable the built-in file editor. It lets an attacker who gets into the dashboard edit your code. Add this line to wp-config.php:

define( 'DISALLOW_FILE_EDIT', true );
  • Use correct file permissions. A common recommendation is 755 for directories and 644 for files, with stricter permissions such as 600 or 440 for wp-config.php. Never use 777.

  • Protect wp-config.php. Keep it above the public web root if your host allows, and ensure the authentication keys and salts are unique and random. You can generate new ones from the official WordPress secret-key service.

  • Disable XML-RPC if you do not use it. It is a common target for brute-force attacks, although some apps and plugins rely on it, so check first.

  • Prevent directory browsing so visitors cannot list the contents of your folders.

  • Block PHP execution in the uploads folder where possible, because uploaded files should never run as code.

9. Apply the principle of least privilege

Give each user only the access they need. Contributors do not need administrator rights. Use the Editor or Author roles for writers, keep the number of administrators small and review the user list every few months. If you hire a developer, give them a separate account and remove it when the work is done.

10. Choose secure hosting

Cheap hosting is often where security problems start. Look for a host that provides isolated accounts, a firewall, malware scanning, automatic backups, current PHP versions, free SSL and fast support. Managed WordPress hosts handle many of these things for you, which is valuable if you are not technical. Avoid putting multiple unrelated sites in one account, because one infected site can spread to the others.

11. Monitor and log activity

Early detection limits damage. Use an activity log plugin to track logins, new users, plugin changes and setting changes. Set up uptime monitoring and email alerts, and sign up for Google Search Console, which can notify you if Google finds malware or hacked content on your site. Watch for warning signs: unexpected admin users, strange redirects, pages you did not create, sudden traffic drops, spam emails sent from your domain and a slow site.

What to do if your site is hacked

  1. Stay calm and take the site offline or enable maintenance mode if visitors are at risk.

  2. Contact your host. Many hosts offer cleanup help and can identify how the attacker got in.

  3. Change every password, including WordPress admin accounts, hosting, FTP or SFTP, the database and email, and regenerate the keys and salts in wp-config.php.

  4. Restore a clean backup from before the infection, if you have one, and then update everything immediately.

  5. Scan and remove malware with a security plugin or a professional service, and delete unknown users and files.

  6. Find and fix the cause, such as the vulnerable plugin, or the attacker will return.

  7. Request a review through Google Search Console if your site was flagged as dangerous.

A simple security checklist

  • WordPress core, plugins, themes and PHP are up to date.

  • Unused plugins and themes are deleted.

  • Strong unique passwords and 2FA for all admins.

  • Login attempts are limited.

  • HTTPS is enforced.

  • Automatic offsite backups with a tested restore.

  • One security plugin plus a firewall.

  • File editing is disabled and permissions are correct.

  • Users have only the roles they need.

  • Monitoring and alerts are on.

Final thoughts

You do not need to be a security expert to protect a WordPress site. Update consistently, choose plugins carefully, use strong logins with two-factor authentication, keep tested backups and add a firewall. Do those things and you are safer than the large majority of websites online. Security is a habit rather than a one-time setup, so schedule a monthly check to review updates, users and backups.

  • backups
  • website security
  • wordpress
  • wordpress security

Comments

Leave a comment

← All posts