Skip to content
WordPress

WordPress Security Guide: Hardening & Malware Removal

Practical WordPress security: updates, logins, roles, hardening, security plugins, backups — and what to do if your WordPress site is hacked.

Hero: padlock and shield over a browser address bar showing HTTPS, for “WordPress Security”
Quick answer

To secure WordPress, keep core, plugins and themes updated, remove unused plugins, use strong passwords with two-factor authentication, give users the lowest role they need, add a firewall and login protection, disable file editing in the dashboard, and keep daily off-site backups. If your site is hacked, restore a clean backup or reinstall core, plugins and themes from official sources, remove unknown users and files, and change every password.

WordPress core is maintained by a dedicated security team, but your site is only as secure as its weakest plugin, theme or password. This guide covers WordPress-specific protections. For general advice see our website security hub.

Common WordPress security issues

WordPress security checklist

01

Update everything

Enable automatic updates for core minor releases and trusted plugins; update the rest weekly.

02

Secure logins

Use unique passwords, two-factor authentication and login rate limiting or CAPTCHA.

03

Use the right roles

Give writers the Author or Editor role, not Administrator, and remove unused accounts.

04

Harden wp-config.php

Use unique security keys and salts and disable file editing (see below).

05

Add a firewall

Use a host or CDN firewall, or a security plugin such as Wordfence, Solid Security or Patchstack.

06

Back up daily

Store backups off-site and test restores.

07

Remove what you do not use

Delete inactive plugins and themes (keep one default theme as a fallback).

// wp-config.php: disable the theme and plugin file editor in the dashboard
define( 'DISALLOW_FILE_EDIT', true );

// Force HTTPS for logins and the admin area
define( 'FORCE_SSL_ADMIN', true );

Tip: If you do not use XML-RPC (for example the mobile app or Jetpack), block it at your firewall or host to cut a common brute-force route.

Best WordPress security plugins

PluginMain strengths
WordfenceEndpoint firewall, malware scanner, login security and 2FA
Solid Security (formerly iThemes Security)Hardening settings, 2FA, login protection
PatchstackVulnerability monitoring and virtual patching for plugins
SucuriCloud firewall, malware scanning and cleanup services

More detail in best WordPress security plugins. Avoid running two firewall plugins at once.

WordPress malware removal

01

Back up the infected site

Keep a copy for investigation before you change anything.

02

Restore a clean backup

If you have one from before the infection, this is fastest.

03

Reinstall core

Dashboard → Updates → Re-install version, or upload fresh core files (keep wp-content and wp-config.php).

04

Replace plugins and themes

Delete and reinstall them from official sources.

05

Clean wp-content and the database

Look for PHP files in /uploads, unknown files, injected scripts in posts and options, and unexpected scheduled tasks.

06

Remove unknown users and reset passwords

Including database, hosting and SFTP passwords, and regenerate security keys.

07

Harden and monitor

Fix the entry point, add a firewall and request a review in Google Search Console if flagged.

Our website malware guide covers detection and recovery in more depth.

Keep learning

More in WordPress

WordPress Guides

A practical, step-by-step guide to creating and running a WordPress website — from installation and settings to design, pages, plugins…

Themes

How to choose a fast, well-supported WordPress theme for a business, store or portfolio — plus a shortlist of popular…

Plugins

The essential WordPress plugins by category — SEO, security, backups, caching, forms, ecommerce and business tools — and how to…

Elementor

A beginner-friendly Elementor tutorial: install Elementor, build your first page, set global styles, make it responsive and keep it fast.

WooCommerce

How to set up a WooCommerce store step by step: install WooCommerce, add products, payments, shipping and taxes, and keep…

WordPress Troubleshooting

A step-by-step method to diagnose WordPress problems, plus quick fixes for the most common errors — from white screens to…

Latest articles

Related WordPress articles

FAQ

WordPress Security questions, answered

Short, honest answers to the questions people ask most about this topic.

Is WordPress secure?

Yes. WordPress core is secure and actively maintained. Most problems come from outdated or poorly coded plugins and themes, weak passwords and poor hosting, which you can control.

It is recommended unless your host or CDN already provides a firewall and malware scanning. A security plugin adds login protection, firewall rules and scanning.

Warning signs include unknown admin users, redirects to spam sites, spam pages in Google, new or modified PHP files, and alerts from your host, browser or Google Search Console.

Changing the login URL can reduce bot noise, but it is not real protection on its own. Strong passwords, two-factor authentication and rate limiting are more effective.

Next step

Keep building your skills

Explore the rest of our WordPress guides, or follow the beginner path step by step.