Most hacked WordPress sites were broken into through an out-of-date plugin or a weak password. The checklist below covers the things that matter most.
Updates
- Update WordPress, themes and plugins as soon as updates appear, from Dashboard, then Updates.
- Switch on automatic updates for plugins and themes in the Plugins list, using Enable auto-updates. Take a backup first for a site you could not afford to break (Backups and how to restore your files).
- Delete plugins and themes you are not using. Deactivated ones can still be exploited.
- Install plugins only from the WordPress directory or from a developer you trust. Avoid pirated "nulled" themes. They often carry malware.
Logins
- Use a long, unique password for every admin (Securing your account with strong passwords and two-factor authentication).
- Do not use
adminas a username. - Add a two-factor plugin for administrators, and a plugin that limits login attempts.
Files
- Folders should be
755and files644. Makewp-config.php600or640. Do this in File Manager with the Permissions button. - Block the built-in file editor by adding this to
wp-config.php:
define('DISALLOW_FILE_EDIT', true);
If you do not use xmlrpc.php (the Jetpack plugin and some mobile apps do), you can block it by adding this to .htaccess:
<Files xmlrpc.php> Order deny,allow Deny from all </Files>
Watch and recover
- Run a scan now and then with cPGuard (Scanning for malware and cleaning up a hacked site).
- Keep your own backups (Backups and how to restore your files).
- Use HTTPS on every page (Forcing HTTPS).
If it doesn't work
- A plugin update broke the site: rename its folder in
wp-content/plugins(WordPress white screen (blank page)) and restore the previous version from your backup. - Locked out after a login plugin: rename its folder the same way to disable it.
- Jetpack or an app stopped working after you blocked xmlrpc: remove the block.