Guide · Strange pop-ups

Strange pop-ups on your WordPress site: where they come from and how to remove them

A pop-up you never added — an ad, a fake prize, a “click allow to continue” notification prompt, a new tab opening to a betting or dating site — is one of the most common signs that a WordPress site has been hacked. It is also one of the easiest to misread. The attacker’s script is usually written to stay out of your sight: it skips logged-in administrators, shows once per visitor per day, or only fires on phones or for visitors arriving from Google. And sometimes the pop-up is not on the site at all, but in the browser of the person who reported it. This guide shows how to tell those apart in a few minutes, where the injected script lives in WordPress, how to find it without changing anything, and what has to happen after you delete it so it does not come back next week.

Symptom
Ads, prize or virus warnings, “allow notifications” prompts or new tabs on your site that you did not add
Why you may not see it
Hidden from logged-in users and repeat visitors, or shown only on mobile or from Google
Usual cause
JavaScript injected into the database, a theme or plugin file, or a header/footer snippet
Typical fix
Remove every copy, then close the way in: a vulnerable plugin, a stolen login or a backdoor

Step one

Is it your site, or the browser that is viewing it?

Two minutes here saves hours of searching a clean site. Adware and notification spam on a visitor’s own device look exactly like site malware to the person who sees them.

  1. 01

    Check from a second, clean device

    Open the site in a private window on a phone on mobile data, or on a computer that is not the one that showed the pop-up. Visit two or three pages, then come back an hour later, because many injections show only once per visitor.

    If the pop-up appears on a clean device, the site is the source. If it appears only on one computer, keep reading this step.

  2. 02

    Look for the same pop-ups on other websites

    If the same kind of ad or prompt appears on unrelated, reputable sites as well, the problem is that browser: an extension, or a site that was once allowed to send notifications. In Chrome, check Settings → Privacy and security → Site settings → Notifications, and remove anything you do not recognise, then review the extensions list.

  3. 03

    Ask the person who reported it for details

    Which device and browser, which page, what the pop-up said, and whether they arrived from Google, an email or by typing the address. A pop-up reported only by visitors from Google is a strong sign of a cloaked injection on the site.

Where it lives

Five places a WordPress pop-up script hides

Most site-side pop-ups are a short piece of JavaScript that loads the real advert or prompt from someone else’s server. It has to be printed into your pages from somewhere, and in WordPress that somewhere is one of these.

Figure 1 · Where an unwanted pop-up comes from

Five sources of a pop-up you never added, and how to tell them apart.

SourceThe sign that points to itWhere to look
Adware on your own devicePop-ups on other websites too, or only in one browserBrowser extensions and notification settings
Script in the databasefromCharCode or an unknown <script src> in page source; files are cleanPosts, widgets, options
Modified theme or plugin fileScript appears on every page, survives a database restoreheader.php, footer.php, functions.php
Hijacked header or footer snippetA snippet you did not add in a code-injection pluginSnippet and header/footer plugin settings
Compromised third-party scriptBegan with no change on your side; many sites affectedAd, chat and analytics tags
Only the first row is not a site problem. Rule it out from a clean device before you start editing anything.

The database

Appended to post content, saved in a Custom HTML or Text widget, or stored in an option that a theme prints in every page. Often encoded with String.fromCharCode or atob() so no address is readable. No file scan sees it.

A theme or plugin file

An extra <script> line in header.php or footer.php, or PHP in functions.php that echoes a script on the wp_head or wp_footer hook. Nulled “free” copies of paid themes often ship with this already inside.

A header and footer snippet plugin

Code-injection and snippet plugins are legitimate, which is exactly why attackers with an administrator login use them: a new snippet survives theme changes and looks like site configuration.

A vulnerable pop-up or form plugin

Pop-up builders store custom JavaScript by design. The December 2023 Balada Injector wave planted its script through Popup Builder (CVE-2023-6000, versions 4.2.3 and older), in a field that site owners rarely open.

A third-party script you load on purpose

An ad network, chat widget or analytics tag that was itself compromised, or a domain a script used to load from that has since expired and been bought by someone else. Nothing on your server changed.

Find it

Read-only checks to find the pop-up script

Each command below only reads. Run them from the WordPress root with WP-CLI, over SSH or your host’s terminal. If you cannot use a terminal, skip to the last step: the page source alone is often enough to know what you are dealing with.

  1. 01

    Fetch the page as a visitor would, not as yourself

    Request the home page as a logged-out phone visitor arriving from Google, and save the result for comparison:

    shell
    curl -s -A "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 Mobile/15E148" -e "https://www.google.com/" https://example.com/ -o visitor.html
    curl -s https://example.com/ -o plain.html
    diff <(grep -o "<script[^>]*>" plain.html | sort -u) <(grep -o "<script[^>]*>" visitor.html | sort -u)

    Replace example.com with your domain. Any script that appears only in the visitor copy is being served conditionally, which legitimate plugins rarely do.

  2. 02

    List every external script the page loads

    From the saved copy, list where each script comes from and look for domains you do not recognise:

    shell
    grep -o '<script[^>]*src="[^"]*"' visitor.html | sed 's/.*src="//; s/"$//' | sort -u

    Your own domain, a CDN you chose, and the services you signed up for are expected. A random-looking domain, or an IP address, is the lead to follow.

  3. 03

    Search the database for injected script

    WP-CLI searches every table, including widgets, options and page-builder data:

    WP-CLI
    wp db search "fromCharCode" --all-tables-with-prefix
    wp db search "<script" --all-tables-with-prefix --stats
    wp db search "atob(" --all-tables-with-prefix

    Expect a few legitimate matches from embedded forms or analytics. Judge each by where its script loads from, and note the table and column of every suspicious one.

  4. 04

    Search the theme and plugin files

    Look for script tags and output hooks added recently:

    shell
    grep -rn --include=*.php -E "wp_head|wp_footer" wp-content/themes/ | grep -iE "script|eval|base64" | head -50
    find wp-content -name "*.php" -mtime -30 -printf "%TY-%Tm-%Td %p\n" | sort -r | head -40
    wp core verify-checksums
    wp plugin verify-checksums --all

    verify-checksums compares Core and WordPress.org plugins against the official copies; anything listed as modified deserves a closer look. Premium plugins are not covered and need comparing with a fresh download.

  5. 05

    Check snippet and pop-up plugins by hand

    Open each code-snippet, header/footer and pop-up plugin you have installed and read every snippet, custom JavaScript field and “custom code” box. List the plugins first:

    WP-CLI
    wp plugin list --fields=name,status,version,update_version

    A snippet you did not write, or a pop-up campaign you did not create, is the injection. Note its creation date: it bounds the time window to search the logs for.

Remove it

Remove the pop-up, then close the way in

Deleting the script takes minutes. Whether it comes back depends on the rest of this list.

  1. 01

    Keep a copy before you change anything

    Export the database and archive wp-content outside the web root. You will want them to find the way in, and to prove the site was cleaned.

    shell
    mkdir -p ~/incident
    wp db export ~/incident/before-cleanup.sql
    tar -czf ~/incident/wp-content.tgz wp-content
  2. 02

    Remove every copy

    Replace modified Core and plugin files with clean copies rather than editing them. Remove the script from the database with WP-CLI search-replace after a dry run, never a raw SQL REPLACE, because widget and option data is serialised and breaks when edited by hand. Delete rogue snippets and pop-up campaigns.

  3. 03

    Find what put it there

    A script in many posts at once, or in a theme file, means someone had write access. Look for administrators you did not create, PHP files in uploads, files in mu-plugins, and an outdated plugin with a known vulnerability. If you find none of these, assume a stolen password.

  4. 04

    Close it and rotate everything

    Update or remove the vulnerable plugin or theme. Change every administrator password and remove unused accounts. Change the database password and the WordPress salts in wp-config.php so stolen sessions stop working.

  5. 05

    Check again tomorrow, from outside

    Repeat the visitor curl and the database search the next day. A pop-up that returns after a careful cleanup means a backdoor or scheduled task survived, which is a different problem from the pop-up itself.

Why it matters

What pop-up malware costs a site if it is left running

Visitors and customers

Fake virus warnings, prize scams and push-notification prompts target the people who trust your site. Some lead to malware downloads or payment fraud.

Google and browsers

Google Safe Browsing flags sites that send visitors to deceptive pages, and Chrome then shows a full-page red warning to every visitor until a review clears it.

Your host

Hosts that receive abuse reports, or whose scanners find the script, suspend accounts first and ask questions later.

Your advertising

Google Ads disapproves ads that point to a compromised site, so paid traffic stops on the same day the warning starts.

Related symptoms

Pop-ups often arrive with redirects, fake updates and spam

The same injected script that shows a pop-up today can be switched to a redirect, a fake browser-update page or a fake CAPTCHA tomorrow, because the payload is chosen on the attacker’s server, not on yours. If the symptom changes while you are investigating, it is the same infection.

Common questions

Common questions about strange pop-ups on WordPress

Why can’t I see the pop-up when my visitors can?

Because the script is written to avoid you. Common rules are: never show to logged-in users, show once per visitor per day using a cookie, show only on mobile, or show only to visitors whose referrer is a search engine. Test from a private window on a clean phone, arriving from a Google search, and wait between attempts.

Could the pop-ups be coming from my own computer instead?

Yes, and it is worth ruling out first. If the pop-ups also appear on unrelated websites, or only in one browser, the cause is a browser extension or notification permission on that device, not your site. Check from a different device on a different network.

Will a security plugin remove the pop-up?

It may remove the script if the script is in a file and matches a known signature. Database injections, hijacked snippets and compromised third-party scripts are often missed, and no plugin removes the backdoor or stolen password that let the script in. That is why pop-ups often return after a plugin reports the site clean.

I deleted the script and the pop-up came back. Why?

Something is still writing it: a backdoor file, a scheduled task, a rogue administrator, or a plugin that is still vulnerable. The pop-up is the symptom; finding the writer is the actual fix.

Is it safe to keep the site online while I investigate?

If visitors are being sent to scams or downloads, putting the site into maintenance mode or behind a password while you work protects them and your reputation with Google. If the pop-up is an advert only, you can usually investigate first, but do not leave it for days.

How much does it cost to have pop-up malware removed?

A single-site cleanup here is a fixed fee from $120 to $500, agreed before work starts, with a reply the same business day and most sites clean within 24–48 hours of access. The fee covers finding the way in and the backdoors, not only the visible script.

Choose the response path

Pop-ups you did not add mean someone else can change your pages. Choose how to close that.

One site with pop-ups now

Get the script, the backdoors and the way in removed in one pass.

Best when visitors are seeing pop-ups, ads or notification prompts today and you want them gone without breaking the site. Fixed fee from $120, a reply the same business day, and a written record of what was found.

After the cleanup

Keep the site watched so the next injection is caught in hours, not weeks.

Best for business sites that cannot afford to find out from a customer again: updates, file and database change monitoring, and a named person to call. From $75 per site per month.