Hi,
It’s pretty easy to do with some basic PHP.
Just use WP template tags https://codex.wordpress.org/Template_Tags to define where you want the banner to be hidden and apply one of the two action hooks:
// Disable Cookie Notice
add_filter( ‘cn_cookie_notice_output’, ‘__return_false’ );
// Disable Cookie Compliance
add_filter( ‘cn_cookie_compliance_output’, ‘__return_false’ );
Hope this helps,
Sorry to jump in but I did just that to achieve something similar (but then site wide).
It then gives an error in the console log:
Uncaught TypeError: Cannot read properties of null (reading 'classList')
at Object.init (front.min.js?ver=2.2.3:1:6939)
at front.min.js?ver=2.2.3:1:8399
It looks to me your js assumes the class is always there. I think you might need to adapt your JS so it can handle it when the class is non-existent.
Just found out, this can be fixed by adding an empty div with id=”cookie-notice”.
function tk_cookie_output( $output ) {
if ( $your_condition ) {
$output = '<div id="cookie-notice"></div>';
} else {
$output = preg_replace('/<!--(.*)-->/Uis', '', $output);
}
return $output;
}
add_filter( 'cn_cookie_notice_output', 'tk_cookie_output' );
If your condition is met, it’s hidden, if not, it strips their branding from the source code.
Thank you @dfactory!
Someone helped me create the following MU plugin (In case anyone else is interested!):
File name: disable-cookie-notice.php
<?php
/**
* Plugin Name: Disable Cookie Notice
* Description: Hides the cookie notice on specific page IDs for the Cookie Notice & Compliance for GDPR/CCPA plugin by Hu-manity.co
*/
function tk_cookie_output( $output ) {
if (is_page(array(123456,789012,345678) ) ) {
$output = '<div id="cookie-notice"></div>';
} else {
$output = preg_replace('/<!--(.*)-->/Uis', '', $output);
}
return $output;
}
add_filter( 'cn_cookie_notice_output', 'tk_cookie_output' );
?>
Note that you can insert multiple page IDs separated by a comma in this section:
if (is_page(array(123456,789012,345678) ) ) {
Or an individual page ID as follows:
if (is_page(array(123456) ) ) {
-
This reply was modified 3 months, 3 weeks ago by
Alex Ford.
-
This reply was modified 3 months, 3 weeks ago by
Alex Ford.