If you have ever configured a popup to disappear after a user clicks “No thanks” or closes it, only to have it reappear on every page load, you are not alone.
This issue is especially common when popups rely on cookies but the logic is split across multiple sources like plugins and theme files. In this guide, we will walk through how to diagnose and fix a recurring popup issue in WordPress, particularly when using custom plugins and third-party integrations like GovDelivery.
Issue Background
A WordPress site was using a “Sign Up for Alerts” popup intended to behave like this:
- User clicks “No thanks”
- Popup disappears
- A cookie is set
- Popup does not reappear for several days
However, the actual behavior was:
- Popup reappeared on every page load
- No clear settings in the WordPress admin to control this behavior
- Popup appeared to be connected to GovDelivery, but no backend controls existed
This created confusion and a poor user experience.
Diagnosis
The root cause was not the cookie itself, but how the popup logic was implemented.
Popup functionality split between plugin and theme
The popup was implemented using a custom plugin called sticky-popup, but the dismiss and cookie logic lived in a theme file:
/wp-content/themes/bb-theme-child/js/custom-script.js
This created a split ownership problem where the plugin depended on the theme for core functionality. The plugin also attempted to load scripts from an incorrect location, which resulted in a 404 error. The functionality only worked because the child theme happened to load the script separately.
Cookie behavior was fragile
Testing showed that a cookie such as popupShown was being set correctly and persisted for several days. However, the implementation was fragile and could fail if cookies were blocked, scripts failed to load, or theme files changed.
No centralized control
Because the logic was split, there was no single place to manage popup behavior, making future updates risky and difficult to maintain.
Resolution Steps
Move all popup logic into the plugin
The solution was to consolidate all functionality into the sticky-popup plugin. A dedicated script such as sticky-popup-dismiss.js was created and enqueued directly from the plugin.
Remove conflicting theme scripts
The following file was removed from the child theme to prevent duplication and conflicts:
/wp-content/themes/bb-theme-child/js/custom-script.js
Properly enqueue scripts in WordPress
The plugin was updated to enqueue its script using WordPress best practices:
wp_enqueue_script(
'sticky-popup-dismiss',
plugin_dir_url(__FILE__) . 'sticky-popup-dismiss.js',
array('jquery'),
null,
true
);
This ensures reliable loading without depending on theme structure.
Validate cookie behavior
After the fix, clicking “No thanks” sets a cookie that prevents the popup from reappearing for several days. The behavior was confirmed across browsers and devices.
Final Outcome
By consolidating logic into the plugin, the popup now behaves consistently and reliably. The dependency on the theme was removed, reducing the risk of future regressions.
This approach also improves maintainability and ensures that updates to the theme do not break popup functionality.
If your WordPress popup is not respecting cookie settings, the issue is often caused by scripts loading incorrectly or logic being split between plugins and themes. Keeping all functionality inside a properly structured plugin is the most reliable solution.
If you are dealing with recurring popups, cookie issues, or plugin conflicts, our team can help diagnose and resolve the problem efficiently.