Harden WordPress: the most important measures against hacks
WordPress itself is well maintained – most successful attacks go through outdated plugins, weak passwords or an insecure server environment. These measures close the most important entry points.
1. Updates – automatic where possible
- WordPress core: WordPress installs security updates automatically by default. Current: WordPress 7.1.4 (28 Oct 2026, fixes the actively exploited flaw CVE-2026-119977). Caution: block
wp-content/upgradebefore updating – see Update WordPress safely. - Plugins and themes: under Dashboard → Plugins, choose "Enable auto-updates" for trusted plugins. Delete unused plugins and themes, don't just deactivate them.
- PHP: use a supported, patched PHP version – see PHP versions & end of life.
2. Protect the login
- Long, unique passwords and two-factor authentication for all accounts with editor or admin rights.
- Don't use a user called "admin"; only as many administrators as necessary.
- Limit login attempts (plugin or your host's web application firewall).
- Block
xmlrpc.phpif no app or Jetpack feature needs it.
3. Harden wp-config.php
define('DISALLOW_FILE_EDIT', true); // no file editor in the dashboard
define('WP_DEBUG', false); // no error messages on the front end
define('FORCE_SSL_ADMIN', true); // dashboard via HTTPS only
The file should not be readable by other users (permissions e.g. 640 or 600) and should contain its own random security keys.
4. Don't reveal versions
The meta generator in the page source and the ?ver= parameters reveal WordPress and plugin versions. Remove the generator in the functions.php
of your (child) theme:
remove_action('wp_head', 'wp_generator');
This does not replace updates, but it makes automated searches for vulnerable sites harder. See also disable expose_php.
5. Files and uploads
- Prevent PHP execution in the uploads folder (e.g. via
.htaccessinwp-content/uploads:<Files *.php> Require all denied </Files>). - Don't keep backups, database dumps or
.ziparchives in the web directory. - Disable directory listing (
Options -Indexes).
6. Backups and monitoring
- Regular, automatic backups of files and database – stored outside the web server and test-restored.
- React quickly to security advisories for plugins you use (e.g. via Patchstack or Wordfence).
- Check your site regularly with the in-depth check – it detects outdated WordPress versions, JavaScript libraries with known vulnerabilities and missing security headers.