How to protect your WordPress site against hackers

Having a WordPress website is an excellent way to share your ideas, sell products, or showcase your work to the world. However, like anything valuable, it’s important to protect it. Hackers may try to access your site to steal information, ruin your content, or even use it for malicious activities. But don’t worry—protecting your WordPress site isn’t as complicated as it seems. Here I explain, in simple terms, how to do it.
Tabla de contenidos
Basic tips
1. Keep everything up to date
The first thing you should do is keep your WordPress updated. This includes the WordPress core, themes, and plugins. Updates not only add new features but also fix security vulnerabilities. An outdated website is an easy target for hackers.
Tip: Enable automatic updates in WordPress to make sure everything stays up to date.
2. Use strong passwords
It may seem obvious, but many people still use weak passwords like “123456” or “password.” A strong password should be long and combine uppercase and lowercase letters, numbers, and symbols. Also, it’s important not to reuse the same password across multiple sites.
Tip: Use a password manager to generate and store strong passwords without having to memorize them.
3. Remove what you don’t use
If you have themes or plugins you don’t use, delete them. Every inactive theme or plugin is an open door for hackers. Plus, these unnecessary files can slow your site down.
Tip: Regularly review the plugins and themes you have installed and remove those you don’t need.
4. Install a security plugin
There are security plugins that can help protect your website. Some popular ones are Wordfence, Sucuri, or iThemes Security. These plugins can scan your site for malware, block suspicious login attempts, and much more.
Tip: Configure these plugins to send you alerts if they detect anything unusual on your site.
5. Change the login URL
By default, the WordPress login page is “yourwebsite.com/wp-admin.” Hackers know this and often try to access it with username and password combinations. Changing this URL to something different can make it harder for them to find the entry point.
Tip: Use a plugin like WPS Hide Login to change the login URL.
6. Limit login attempts
Sometimes hackers try to access your site by testing thousands of username and password combinations in a short time. Limiting the number of login attempts is an effective way to stop these attacks. You can configure WordPress to block a user after several failed attempts.
Tip: Many security plugins include this feature, so make sure to enable it.
7. Make regular backups
No one is completely safe from being hacked, even with the best precautions. That’s why it’s vital to back up your website regularly. If something goes wrong, you can restore your site to a previous state without losing too much work.
Tip: Use a backup plugin like UpdraftPlus or BackupBuddy, and store backups in a secure place like Google Drive or Dropbox.
8. Disable file editing from the WordPress dashboard
WordPress allows you to edit files like the theme and plugins directly from the dashboard. However, if a hacker gains access to your account, they can use this feature to inject malicious code. Disabling it adds an extra layer of security.
Tip: You can disable this feature by adding the following line of code to your wp-config.php file:
define( 'DISALLOW_FILE_EDIT', true );
9. Use two-factor authentication (2FA)
Two-factor authentication adds an extra layer of security. In addition to your password, you’ll need a second code sent to your phone to log in. This makes it much harder for hackers to access your account.
Tip: Plugins like Google Authenticator or Authy let you set up two-factor authentication in WordPress.
10. Monitor your website regularly
Last but not least, it’s important to keep an eye on your website. Regularly check for suspicious changes, such as new users you don’t recognize or content modified without your authorization.
Tip: Establish a routine to review your site and make it part of your monthly calendar.
Advanced tips
1. Use a Web Application Firewall (WAF)
A web application firewall acts as a shield between your site and malicious traffic. It can block attacks before they reach your server. Some WAF providers include Cloudflare, Sucuri, and Wordfence. This type of protection is especially useful against brute-force attacks and other common threats.
Tip: Configure a WAF to run in “full protection” mode, filtering all traffic before it reaches your site.
2. Change the database prefix
By default, WordPress uses the wp_ prefix for all its database tables. Hackers know this and often use it to run automated SQL injection attacks. Changing this prefix to something more unique can make their job harder.
Tip: You can change the database prefix during WordPress installation or use plugins like “Brozzme DB Prefix & Tools Addons” to do it safely on an existing site.
3. Disable XML-RPC
The XML-RPC.php file allows external applications to interact with your WordPress, but it’s also a frequent target of brute-force attacks. If you don’t need this feature, it’s better to disable it.
Tip: You can disable XML-RPC by adding this code to your .htaccess file:
# Block requests to XML-RPC
<Files xmlrpc.php>
order deny,allow
deny from all
</Files>
4. Configure HTTP Security Headers
HTTP security headers are an advanced way to protect your site against common attacks like XSS (Cross-Site Scripting) or clickjacking. These headers are configured on the server and add an extra layer of protection.
Tip: Set headers like Content-Security-Policy, X-Frame-Options, X-Content-Type-Options and Strict-Transport-Security. You can do this through your server or by using plugins like “HTTP Headers”.
5. Force HTTPS across the entire site
Make sure your site uses HTTPS on all its pages. This protects data transmission between the server and the user, which is crucial to prevent man-in-the-middle attacks.
Tip: Get an SSL certificate from a trusted authority and then force HTTPS on your site through your control panel or by using plugins like “Really Simple SSL”.
6. Use public/private key-based authentication
This method is an even more secure alternative than two-factor authentication. Instead of a password, you can use a pair of cryptographic keys (one public and one private) to authenticate.
Tip: If you’re familiar with SSH, you can configure your server to allow logins via keys only, significantly reducing the chances of a successful attack.
7. Continuous auditing and monitoring
Implement a monitoring system that logs all activities on your website. This includes logins, file changes, content modifications, etc. If something suspicious happens, you’ll receive an alert.
Tip: Plugins like “WP Activity Log” or “Stream” are excellent options to keep a detailed record of what’s happening on your site.
Final words
Protecting your WordPress site from hackers doesn’t have to be complicated. With these simple measures, you can significantly reduce risks and keep your website secure. Remember, security is an ongoing process, so always stay alert and up to date. Your site and your visitors will thank you!


