Common mistakes and good habits
Keep your WordPress site safe with simple habits: updates, tested backups, strong passwords, least-privilege roles and what to do if something goes wrong.
In this lesson you will
- Apply updates and take backups properly
- Use strong passwords and sensible roles
- Spot early warning signs
- Respond if a site is hacked
About 15 minutes
Why sites get hacked, and why it is rarely clever
Layla’s blog was fine for a year. Then one morning, her homepage showed strange advertisements for something she had never heard of. The cause was not a genius hacker. It was an old plugin she had forgotten to update, and a weak password she had used on three other sites. Most attacks on small sites are automatic, run by programs scanning for the same few weaknesses. That means a few steady habits protect you from most of them.
Habit 1: Updates
Updates fix security holes. WordPress itself, themes and plugins all publish them. Take a backup, apply updates regularly (for example once a week), and check the site afterwards. Many hosts and WordPress can apply minor security updates automatically. Remove software you no longer use, since it also needs updates.
Habit 2: Backups you can restore
A backup is your undo button for the whole site. It must include both the database (your content and settings) and the files (themes, plugins, uploads). A good rule is 3-2-1: three copies, on two kinds of storage, with one kept off the server. Test a restore at least once, because a backup you have never restored is only a hope. Check what your host already provides, and whether copies are kept long enough to go back before a problem started.
Habit 3: Strong passwords and two-step login
- Use a long, unique password for every account. A password manager makes this easy.
- Turn on two-step verification if your host or a trusted plugin offers it.
- Do not use admin as a username.
- Never share your login. Create separate users for other people.
Habit 4: Give people only the access they need
WordPress has roles with different powers. A test site was asked what two roles can do, and how a password is stored. The output is real:
esc_html: <script>alert(1)</script> Tom & Jerry
sanitize_text_field: Tom & Jerry
stored hash looks like: $wp$... (63 characters, not the password)
check right password: true
check wrong password: false
contributor can publish_posts: no
editor can install_plugins: no
administrator can install_plugins: yes
Two lessons appear. First, a contributor can write but not publish, and only an administrator can install plugins, so give a helper the lowest role that lets them work. Second, the stored hash is not the password. WordPress keeps a scrambled version, and checks a typed password against it, so even a wrong capital letter fails. That is why you should never email your password or store it in a document.
Habit 5: Clean input and output (for later)
The first two lines of the output show how WordPress treats risky text. esc_html turns a script tag into harmless visible characters, and sanitize_text_field strips tags before saving. Developers use these on all user input. As a site owner, the lesson is that plugins and themes written carefully use these tools, which is another reason to choose well-
Habit 6: Spam and comments
- Require approval for first-time commenters, or close comments on old posts.
- Use a trusted spam filter.
- Do not click links in strange ‘WordPress alert’ emails. Go to your dashboard yourself.
Habit 7: Know what normal looks like
Look at the site as a visitor each week. Check the home page, a few posts, the contact form and the login page. Watch for unknown users, strange new pages, a sudden slowdown or warnings from your host. Early signs are easy to fix; late ones are expensive.
If your site is hacked
- Contact your host; they often help and may have clean backups.
- Change all passwords: hosting, WordPress, email, database.
- Restore a clean backup, or remove the infected files.
- Update everything, and delete unused plugins and themes.
- Check for unknown admin users and remove them.
- Find how it happened, so it does not return.
Practice
Make a one-page security checklist for your site with dates: when you last updated, last tested a backup and last reviewed users. Set a recurring reminder on your phone for one fixed day each week, and do the checklist once now.
A good checklist has five or six lines: updates, backup tested, user list, password manager, spam queue and a look at the live site. The value comes from repeating it, not from a perfect list.
Believing a small site is too small to be attacked. Attacks are automated and do not choose by size. Basic habits matter for every site.
A weekly ten-minute routine
| Minute | Task |
|---|---|
| 1-3 | Apply updates after checking the backup is recent |
| 4-5 | Clear the spam queue and approve real comments |
| 6-7 | Look at the user list for names you do not know |
| 8-10 | Visit the site as a stranger on your phone |
Ten minutes a week is far cheaper than a day spent cleaning a hacked site. Put the routine in your calendar so it happens even when you are busy.
Check what you learned
Five quick questions. Pick an answer and you will see straight away whether it is right and why.
What must a good backup include?
- Only the logo
- Only the theme
- Only comments
- Database and files
Content lives in the database, media and code in files.
What does the 3-2-1 rule suggest?
- One copy, one place
- Three copies, two storage types, one off-site
- Three passwords
- Two plugins
It protects against several kinds of loss.
Why use the lowest role that works?
- It saves money
- It changes the theme
- Limits the damage a mistake or stolen login can do
- It speeds the site up
Least privilege is a core habit.
What does WordPress store for a password?
- A scrambled hash, not the password
- The password in plain text
- Your email
- A photo
It compares the typed password with the hash.
What is the first thing to do if hacked?
- Ignore it
- Buy ten plugins
- Contact your host and change passwords
- Rename the site
Then restore and clean.
Summary
- Update regularly and delete unused software.
- Back up database and files, and test a restore.
- Strong unique passwords, two-step login, minimal roles.
- Check your site weekly.
Questions
Do I need a security plugin?
Not always. Updates, backups, strong passwords and good hosting do most of the work. A reputable security plugin can add login protection and scanning.
How often should I back up?
Match it to how often content changes. A busy shop needs daily or more often; a small brochure site may need weekly.
Is it safe to use a free Wi-Fi to log in?
Prefer a trusted connection. Make sure the site uses HTTPS, and avoid logging in on shared computers.
