12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Nov 17, 2018

How to set up a Cookie Consent bar in WordPress

Sridhar Katakam

This tutorial provides the steps to display a fixed cookie consent bar that can be dismissed by your site visitors at the bottom of your site.

Step 1

Go to https://cookieconsent.insites.com/download/, configure the cookie consent bar to your liking and you should see the generated code.

In this example, we shall go with the default one.

Step 2

Install and activate Code Snippets plugin.

Go to Snippets > Add New.

Title: Cookie Consent


add_action( 'wp_head', 'custom_cookie_consent' );
 * Add Cookie Consent bar.
 * @link https://cookieconsent.insites.com/download/ Code generated from here.
function custom_cookie_consent() { ?>

    <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css" />
    <script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script>
    window.addEventListener("load", function(){
      "palette": {
        "popup": {
          "background": "#000"
        "button": {
          "background": "#f1d600"

<?php }

Replace the code above in between function custom_cookie_consent() { ?> and <?php } with the code generated in the earlier step.

Set it to run only on the front-end.

Save and activate.