--- title: "Add a cookie consent banner to WordPress without a subscription: a plugin you can build today" description: Most cookie consent plugins push you toward a paid plan for consent logs or script scanning. Here is a minimal plugin that shows the banner and remembers the answer. source: https://steem.dev/blog/wordpress-cookie-consent-banner-plugin published: 2026-09-01 updated: 2026-09-01 alternative_to: Complianz site: Steem — AI WordPress plugin generator --- # Add a cookie consent banner to WordPress without a subscription: a plugin you can build today Every WordPress site serving visitors in the EU needs to tell them about cookies before dropping non-essential ones. The plugins that handle this range from adequate to expensive. The free tiers usually work for a basic banner, but they often include persistent upgrade prompts, a third-party SaaS connection for consent logging, or mandatory branding that cannot be removed without paying. For a developer or agency managing a small site where the tracking setup is already known, that overhead is unnecessary. The job is genuinely small: show a banner, wait for a click, remember the answer. A plugin that does exactly that, with no third-party service and no upgrade screens, is about fifty lines of PHP and a few lines of JavaScript. That is what this guide builds. The consent logic is yours to wire up, which means you control what actually fires before acceptance. Here is the prompt. ## What one build covers - Cookie consent banner injected into wp_footer, shown only until the visitor has set a preference - Accept and Decline buttons that each set a 365-day browser cookie and dismiss the banner - Settings page for banner message and button labels, with no third-party service or external dependency - JavaScript CustomEvent and global status function so theme scripts can check consent before firing ## What it does not cover - Consent log with timestamps and IP addresses for regulatory audit trails - Automatic cookie scanning and categorization of what your site sets - Granular consent categories (analytics, marketing, functional) with per-category script blocking - Script auto-blocking: tracking scripts must be conditionally loaded in the theme or via a follow-up build - IAB TCF 2.0 compliance required by programmatic advertising networks ## The prompt ```text Build a WordPress plugin that adds a GDPR cookie consent banner. Hook into wp_footer to output the banner HTML only on the front end (skip when is_admin() is true) and only when the JavaScript cookie named 'wp_cookie_consent' is not already set to 'accepted' or 'declined'. The banner uses position: fixed at the bottom of the viewport, full width, with a white background, a 1px solid #e5e5e5 top border, padding of 1rem 1.5rem, and a flexbox layout with the message text on the left (flex: 1) and two buttons on the right with a 0.5rem gap between them. The Accept button has background: #111 and color: #fff with 0.5rem 1rem padding and no border. The Decline button has background: transparent, border: 1px solid #111, and color: #111 with the same padding. Both buttons set the 'wp_cookie_consent' cookie via document.cookie to either 'accepted' or 'declined' with max-age=31536000, path=/, SameSite=Lax, then call a function that removes the banner element from the DOM and dispatches a CustomEvent named 'cookieConsentResolved' on the document with detail set to 'accepted' or 'declined'. Expose window.wpCookieConsentStatus() as a global function that reads the wp_cookie_consent cookie value from document.cookie and returns 'accepted', 'declined', or null. Enqueue the JavaScript with wp_enqueue_script and add all CSS with wp_add_inline_style. Add a settings page registered under Settings using add_options_page with menu title 'Cookie Consent'. Register three text options using the Settings API under the option group wp_cookie_consent_settings: banner_message (default: 'This site uses cookies to improve your experience.'), accept_label (default: 'Accept'), and decline_label (default: 'Decline'). Read these options when rendering the banner. Do not write to the database beyond those three Settings API options. Do not add any admin menu items beyond the single settings page. ``` ## Why the free tier is never quite free Cookie consent plugins are freemium by design. The basic banner is free because the real product is consent logging, cookie scanning, and multi-site management. Those features cost money to run and that is where the subscription goes. For sites where the developer knows the full cookie inventory and handles script loading in the theme, none of those features are needed. The site has Google Analytics, maybe a Meta Pixel, and a session cookie from WooCommerce. The developer knows what requires consent. What is needed is a banner that communicates that clearly and a preference store that lasts across sessions, without any third-party service in the middle. ## What the plugin builds The plugin hooks into wp_footer to inject a fixed banner at the bottom of the screen whenever the visitor has not yet set a preference. The banner shows a configurable message and two buttons: Accept and Decline. Clicking either sets a browser cookie named wp_cookie_consent for 365 days and removes the banner from the page. After the banner resolves, the plugin fires a JavaScript CustomEvent called cookieConsentResolved on the document, with a detail value of either accepted or declined. A global function window.wpCookieConsentStatus() returns the current preference at any time by reading directly from the browser cookie. A settings page under Settings > Cookie Consent lets the site owner edit the banner message and both button labels. Nothing is written to the WordPress database beyond those three settings. No consent log, no audit trail, no external call. ## Who this is for Developers and agencies who manage their own script loading. If you add Google Analytics or a Meta Pixel directly in the theme, you can wrap those snippets in a check against window.wpCookieConsentStatus() or listen for the cookieConsentResolved event. The plugin handles the UI; you handle what actually fires. Small sites with a known, minimal cookie footprint. A brochure site with one analytics script and a contact form does not need automated scanning. The developer knows the full picture already. Anyone who wants a banner with their own copy, no third-party branding, no upgrade notices, and no external dependency. ## Who should use a different approach If you need a tamper-proof consent log with timestamps and IP addresses for regulatory audit, this plugin does not provide that. Complianz and CookieYes both offer consent logging on their free and paid tiers, and that is the right tool for sites that need to demonstrate compliance to a regulator. If you need automatic cookie scanning, this plugin does not scan. It displays whatever message you configure. Sites where the cookie inventory is large or changes often, or where non-developers need to maintain the consent record, should use a plugin that handles discovery. If you need IAB TCF 2.0 support for programmatic advertising, this is not the right plugin. Programmatic networks require a certified consent management platform, and that is a different product category entirely. ## How to build it Paste the prompt below into Steem. The plugin downloads as a zip and installs under Plugins > Add New > Upload Plugin. Once active, visit Settings > Cookie Consent to set your banner message, then open the site in a private browser window to confirm the banner appears. Accept or decline, then reload: the banner should not reappear. Two useful follow-ups: 'add a privacy policy URL field to the settings screen and render it as a link inside the banner message' adds the pointer to your cookie policy that most regulations expect. 'Add a shortcode that renders a link a visitor can click to reset their preference and see the banner again' gives returning visitors a way to change their mind, which is the standard approach for a manage-cookies link in the footer. ## Questions ### Does this make my site GDPR compliant? The banner collects and stores the preference. Compliance depends on whether your tracking scripts actually respect that preference. The plugin fires a JavaScript event and exposes a status function so you can make analytics or ad scripts conditional on acceptance, but wiring those up is a code change in your theme or another plugin. ### Where is the consent preference stored? In a browser cookie for 365 days. Nothing is sent to a server or stored in WordPress. If a visitor clears their browser cookies, the banner reappears. ### Can I link to my cookie policy from the banner? Not with the default build. Ask Steem to add a privacy policy URL field to the settings screen and render it as a link inside the banner message. One follow-up message is enough. ### Does this work with WooCommerce? Yes. WooCommerce session and cart cookies are generally considered strictly necessary and exempt from consent requirements under most interpretations. The plugin targets analytics and marketing cookies, which you wrap conditionally in your theme. ### Can visitors withdraw their consent after accepting? Not with the default build. Ask Steem to add a shortcode that resets the preference cookie and shows the banner again. That is the standard approach for a manage-cookies link in the footer. --- Source: https://steem.dev/blog/wordpress-cookie-consent-banner-plugin Build this plugin: https://steem.dev/app