WordPress Hacking: How Sites Get Compromised and How to Prevent It

WordPress security and protection icon

WordPress powers a significant share of the web and that popularity makes it an attractive target for attackers. Hacked WordPress sites is used to distribute malware, send spam, host phishing pages or redirect visitors to malicious destinations. The damage goes beyond technical headaches. A compromised site erodes customer trust, can result in search engine blacklisting and may breach data protection obligations under UK law. Fortunately, most WordPress hacks are entirely preventable. They rely on known vulnerabilities, weak credentials and neglected updates rather than sophisticated zero-day exploits. WordPress support services for UK businesses help businesses keep their sites locked down, but understanding how attacks work puts you in a far stronger position to protect your own site.

You’ll see the most frequent ways hackers break into WordPress sites and learn to catch problems before they spiral out of control. We’ve also included actionable steps to strengthen your defences, whether you handle WordPress maintenance yourself or collaborate with developers.

Prevention sits at the centre of an ongoing professional WordPress support arrangement is what stops the same problem coming back.

How WordPress Sites Get Hacked

Bots run most WordPress attacks these days. They scan thousands of websites looking for known weaknesses and exploit anything they discover without any human involvement whatsoever.

Attack Vector How It Works Primary Defence
Outdated plugins or themes Attackers exploit publicly disclosed vulnerabilities in older versions Keep everything updated
Brute force attacks Automated tools try thousands of username/password combinations Strong passwords, login limiting, two-factor authentication
Weak or reused passwords Credentials obtained from other breaches are tried against your login Unique passwords, password manager use
SQL injection Malicious database queries are inserted through poorly coded input fields Use reputable plugins, keep software updated
Cross-site scripting (XSS) Malicious scripts are injected into pages viewed by other users Input sanitisation, content security policy headers
File inclusion exploits Attackers manipulate file paths to execute malicious code on the server Proper file permissions, disable file editing in wp-admin
Compromised hosting environment Other sites on the same shared server are used as an entry point Quality hosting with proper account isolation

Plugin vulnerabilities are behind more WordPress breaches than any other attack vector. Developers release patches for security flaws, but those patch details become public information that attackers can study. They reverse engineer what went wrong and then hunt for websites still running the vulnerable code. Most successful attacks happen during that window between patch release and when website owners apply the update. The OWASP Web Security Testing Guide explains these patterns in detail for anyone wanting deeper knowledge of web application security.

Signs Your WordPress Site Has Been Hacked

Some attackers work quietly to avoid detection while others make their presence obvious through defaced pages or malicious redirects. Spotting compromises quickly reduces the overall damage, which makes recognising warning signs for any site owner.

Visitors start getting bounced to gambling sites or pharmaceutical pages they never clicked on and that’s your first clue that malicious code has burrowed into your files or database. These unexpected redirects are dead giveaways something’s gone wrong. But here’s the tricky bit: you might miss it completely since the redirect code often leaves admin users alone when they’re logged in.

  • New user accounts appearing in your WordPress admin that you didn’t create, particularly accounts with administrator privileges.
  • Modified files, especially in the wp-includes or wp-admin directories. Your hosting file manager or an FTP client can show recently changed files by sorting by modification date.
  • Unfamiliar code injected into theme files, particularly header.php, footer.php or functions.php. This often appears as base64-encoded strings or obfuscated JavaScript.
  • Your site being flagged by Google Safe Browsing with a “This site may be hacked” warning in search results or a red interstitial warning page in Chrome.
  • A sudden drop in search traffic, which can indicate that Google has identified malicious content and is suppressing your pages from results.
  • Outbound spam being sent from your server, which your hosting provider may alert you to before you notice it yourself.

Time isn’t on your side once attackers get in because they’ll keep digging deeper into your system, turning what could be a quick fix into a complete mess.

Immediate Steps After a Hack

Website security hardening icon

Nobody wants to deal with a hack, but losing your head won’t fix anything. Contain the damage first, then rip out every piece of malicious code and seal up whatever entry point they used to break in.

Every password needs changing immediately. Your WordPress admin login, hosting control panel, FTP access, database credentials, everything. Get a password manager to generate strong ones and don’t you dare reuse anything old. Credential stuffing attacks rely on people recycling passwords, so fresh ones will slam the door on any access points they’ve already compromised.

Restore that clean backup the second you find it. You’ll get back to a working site in minutes instead of spending days picking through infected files. Once you’re live again though, update absolutely everything before you do anything else. WordPress core, plugins, themes, the lot. That same vulnerability is still there waiting for the next attack if you don’t patch it.

Manual cleanup becomes your only option without backups. The WordPress hardening guide shows you where to focus your efforts. Download fresh copies of wp-admin and wp-includes, then comb through wp-content for anything that looks wrong. PHP files hiding in uploads folders shouldn’t exist at all. And don’t forget your database because hackers malicious code into wp_options and post content fields constantly. Search engines will hammer your rankings if they detect compromised content, which makes this cleanup work for technical SEO.

Hardening WordPress Against Attacks

Stopping hacks before they happen saves you weeks of headaches and some reputation damage never fully heals. Keep everything updated and you’ll dodge most attacks completely. Set WordPress to auto-update minor versions and check for plugin updates every week. Staging environments let you test updates safely before they go live, so there’s no excuse for running outdated software that leaves you vulnerable.

Two-factor authentication blocks attackers cold, even when they’ve cracked your password. Strong, unique passwords for every WordPress admin account are non-negotiable, but 2FA takes protection way further by demanding that second verification step. Decent 2FA plugins exist and some managed hosting providers build it right into their server setup. Brute force attacks? They fall apart when you limit login attempts because suddenly those thousands of password combinations hit a wall.

The default WordPress login URL at /wp-login.php and the XML-RPC endpoint at /xmlrpc.php are the two most frequently targeted entry points. Disabling XML-RPC if you don’t use it and rate-limiting login attempts, significantly reduces your exposure to automated attacks.

File permissions get ignored by most site owners but they shouldn’t. Your wp-config.php needs locking down to 440 or 400 so the server can read it but nothing writes to it, directories want 755 and files need 644. Don’t ever use 777 permissions because that lets any server process mess with your files and attackers will thank you for it. And drop define('DISALLOW_FILE_EDIT', true); into wp-config.php to kill the WordPress dashboard’s theme and plugin editor since hackers who get admin access use that editor to inject their code straight away.

The Role of Hosting in WordPress Security

Quality WordPress hosting makes or breaks your security at the foundation level. Server-level firewalls catch malicious traffic before it gets near your site, current PHP and database versions patch vulnerabilities right in the infrastructure and regular malware scanning runs alongside proper backup systems. Account isolation stops compromised sites on shared servers from attacking yours. Web development teams know to look beyond headline specs when choosing hosts because these security practices matter more than raw performance numbers.

Security headers like Content-Security-Policy, X-Content-Type-Options and Strict-Transport-Security aren’t bulletproof but they tell browsers how to handle your content and connections properly. Common exploit techniques become much trickier when these server-level headers are configured correctly and your hosting setup needs to support them. The Google Search Central documentation explains how Google’s crawlers work with sites, so keeping your server secure and properly configured means search engines can access everything without problems.

Security Headers and Additional Protections

Throwing everything at one security measure is asking for trouble. You want layers working together because attackers rarely give up after hitting the first barrier and updates plus strong passwords only get you so far.

SSL certificates encrypt everything flowing between browsers and your server, which stops credentials and personal data travelling as readable text. Force HTTPS across every page and check your hosting supports current TLS versions. Search engines boost HTTPS sites in rankings too, so you’re getting security and SEO wins rolled into one.

Malicious code can lurk undetected for months before anyone notices the damage. File integrity monitoring catches these intrusions by comparing your WordPress files against clean versions and alerting you when something changes without permission. Most quality plugins include this feature and many managed hosts throw it in automatically. The National Cyber Security Centre’s small business guide has solid advice on protecting digital assets that applies perfectly to WordPress sites.

Don’t leave that default wp_ database prefix sitting there like a welcome mat for attackers. Your database user needs minimal permissions, not root access that lets them wreak havoc across your entire system. But the real work comes from regular database audits, especially checking users and options tables where hackers plant their backdoors. Good WordPress maintenance and security means running these database checks alongside your file monitoring.

Why Ongoing Maintenance Matters

Security threat prevention icon

WordPress security isn’t a set-it-and-forget-it thing, even though your site felt bulletproof six months back. Hackers are constantly developing new attack methods while vulnerabilities surface weekly and your plugins keep changing.

WordPress core needs regular updates along with every plugin and theme you’re running. Dump those old user accounts that serve no purpose and make sure file permissions haven’t shifted somewhere they shouldn’t be. But you’ve got to check your error logs because they’ll flag suspicious activity that you’d otherwise miss completely. Test your backups before disaster strikes because discovering they’re useless during an actual emergency is about the worst timing possible.

When your website generates genuine revenue or manages important customer touchpoints, professional maintenance becomes worthwhile. We keep tabs on everything, push updates through staging environments first and run regular security scans with proper incident response protocols ready. Recovery always costs more than prevention and that’s without considering the reputation damage or how your search rankings take a beating. The impact on SEO when a site is compromised lingers for months after you’ve sorted the hack.

Skipping basic security creates the exact conditions attackers love. We’re talking weak passwords, plugins that haven’t been updated in months, cheap hosting providers who skimp on security measures and websites with zero monitoring in place. WordPress has strong security built in when you maintain it properly and stick to proven practices.

FAQs

How do most WordPress sites get hacked?

The vast majority of WordPress hacks exploit outdated plugins with known vulnerabilities rather than sophisticated zero-day attacks. When plugin developers release a security patch, the vulnerability details become public, giving automated bots a roadmap to find sites still running the old version. Brute force attacks against weak passwords, SQL injection through poorly coded input fields and compromised shared hosting environments are the other common entry points.

What are the signs that a WordPress site has been hacked?

Watch for visitors being redirected to gambling or pharmaceutical spam sites, new admin accounts appearing that nobody created and unfamiliar code injected into theme files. Google Safe Browsing warnings in search results, sudden traffic drops, outbound spam being sent from your server and modified files in wp-includes or wp-admin directories are all strong indicators. The sneaky infections often only redirect non-admin visitors, which is why other people usually spot the problem before you do.

What should I do immediately after discovering my WordPress site has been hacked?

Work through it systematically rather than panicking. Change every password connected to the site including WordPress admin, hosting panel, SFTP and database credentials. Check for unknown user accounts with administrator privileges and remove them. Put the site into maintenance mode to stop serving infected pages to visitors and contact your hosting provider, as they may have access logs that reveal exactly how the attackers got in.

Avatar for Paul Clapp Paul Clapp
Co-Founder at Priority Pixels

Paul leads on development and technical SEO at Priority Pixels, bringing over 20 years of experience in web and IT. He specialises in building fast, scalable WordPress websites and shaping SEO strategies that deliver long-term results. He’s also a driving force behind the agency’s push into accessibility and AI-driven optimisation.

Related WordPress Insights

Updates on WordPress development, from Gutenberg and full site editing to performance, security and plugin best practices.

What is a CDN and why do you need one for your WordPress Website?
B2B Marketing Agency
Have a project in mind?

Every project starts with a conversation. Ready to have yours?

Start your project
Web Design Agency