Hide the cookie banner on specific pages
Sometimes a page should not show a banner — for example an internal landing page, a payment-provider return page, or a page with no tracking at all. CookieRay has a filter for this.
Before you start
When CookieRay is switched off for a page, it is switched off entirely for that page:
- No banner or preferences button.
- No browser-side script blocking and no restoring of blocked scripts.
- No Google Consent Mode defaults.
- No consent is recorded there.
So only hide the banner on pages that do not load tracking scripts. A tracker added by hand to a hidden page has no consent check at all. In Strict mode, a known tracker that WordPress itself enqueues on a hidden page may also stay blocked, because the script that restores it after consent does not run there. Pro integration tags (GTM, Meta Pixel, Adobe) and the trust badge are also still output on hidden pages. Test the page in Strict mode before you rely on it.
Hide it on one page
Add this to your child theme’s functions.php or a code-snippets plugin. Change contact-thanks to your page’s slug.
add_filter( 'cookieray_should_load_banner', function ( $load ) {
if ( is_page( 'contact-thanks' ) ) {
return false;
}
return $load;
} );
Hide it on several pages or a post type
add_filter( 'cookieray_should_load_banner', function ( $load ) {
if ( is_page( array( 'contact-thanks', 'order-received' ) ) || is_singular( 'landing' ) ) {
return false;
}
return $load;
} );
WordPress conditional tags such as is_page(), is_singular() and is_front_page() work because the filter runs while the page head is being built.
Check it worked
- Open the page in a private window. No banner should appear.
- In developer tools → Network, confirm the page doesn’t request your tracking scripts. If it does, remove them from that page or don’t hide the banner there.
- Open another page on your site. The banner should still appear.
If you use full-page caching, clear the cache after adding the code.
Related
- Developer Hooks
- Geo Targeting (Pro) — hide the banner by visitor country instead of by page.