Cookie notifier insert!

Hello so i’m using the https://www.osano.com/cookieconsent/download/ open source cookie notifier !
So far I’ve meddled with my child theme’s functions.php and inserted this :

/**
Cookie consent code on head
*/

add_action('wp_head','cookie_consent');

function cookie_consent () { ?>

<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.css" />

<script src="https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.js" data-cfasync="false"></script>

<script>

window.cookieconsent.initialise({

  "palette": {

    "popup": {

      "background": "#000000",

      "text": "#ffffff"

    },

    "button": {

      "background": "#0d66d0",

      "text": "#ffffff"

    }

  },

  "theme": "classic",

  "position": "bottom-left",

  "content": {

    "message": "Acest site folosește cookie-uri pentru a-ți putea oferi o experiență superioară. ",

    "dismiss": "OK",

    "link": "Despre cookie!",

    "href": "dopmotorsport.ro/cookie/"

  }

});

</script>
<?php }

But it doesn’t work, i’ve tried modifying the header.php in my chil themes fodler by inserting the line :

<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/cookieconsent@3/build/cookieconsent.min.css" /> and i get a big time error.

So where the heck do i insert these codes ? Is my function even ok ? Or do i need to do a :

function my_new_action() {
// Things the new action does.
}
add_action( 'x_before_site_begin', 'my_new_action', 10 ); ??

I’m so confused right now …

Hi Alexandru,

The code you are trying to add should go to inside the <head> area of the page so adding it through the wp_head hook just like what you did in the functions.php of the child theme.

Kindly make sure that your child theme is the active theme. If it is already the active theme but you are still not able to see the code in the header area, please provide us with the admin access to your site in a Secure Note:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.