• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to user navigation

Designody

WordPress and Genesis Tutorials

  • Get Started
  • About
  • Archive
  • Services
  • Membership
  • My Account

Cookie Consent bar in Genesis

Last Updated on May 8, 20192 Comments Favorited: 2 times

This tutorial provides the steps to add a Cookie Consent bar in Genesis based child themes.

Works with other WordPress themes too.

STEP 1

Go to https://cookieconsent.insites.com/download/ and configure the cookie consent design and compliance type.

You can see the live Preview or see Cookie Consent demos. https://cookieconsent.insites.com/demos/

STEP 2

Open functions.php of your child theme and add the following:

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

	<!-- Cookie Consent -->

<?php }

Copy the code from the Cookie Consent site and paste it after the line

<!-- Cookie Consent -->

Example:

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

	<!-- 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>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
  "palette": {
    "popup": {
      "background": "#000"
    },
    "button": {
      "background": "#f1d600"
    }
  },
  "theme": "classic",
  "position": "bottom-left"
})});
</script>
<?php }

Related Posts

  • Sticky site header and Notification bar in Genesis
  • Top Notification Bar with close button in Genesis
  • Add Beautiful Notification Boxes with Icons in your site
  • Add Simple Colored Content Boxes in your site

Categories: Free Content, Genesis Tutorials, WordPress Tutorials Tags: Cookie Consent, GDPR, notification bar, notification box

Reader Interactions

Comments

  1. Anthony Ananich says

    September 6, 2020 at 3:53 pm

    It would be better to split Osano code into two parts and load CSS in head, but JavaScript in the end of the body. This could be achieved by adding
    add_action( 'wp_footer', 'custom_cookie_consent_body' );

    Reply
    • Aryan Raj says

      September 8, 2020 at 12:18 pm

      Yes, Correct. However, it seems like Cookie Notice need to show first so i just used wp_head.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You should use these Shortcodes tag and attributes while sharing the code:
Example: [html]I <3 HTML[/html] → [html][css][php][js][java][json][raw]

Primary Sidebar

WPEngine WordPress Hosting, Perfected.

Hosting You are looking for?.
Perfect solution for small business to global enterprise.

Learn more

StudioPress Genesis Theme Framework

The No.1 Theme Provider.
Creative, SEO rich Theme for all niche projects.

Learn more

Categories

  • Free Content
  • Genesis Tutorials
  • Premium Content
  • Snippets
  • What's New?
  • WordPress Tutorials

Tag Cloud

Archive Background Section blog center logo columns conditional tags CSS CSS Grid custom Customizer custom post type Custom Post Types custom template Custom Widget effect Featured Image front-page Genesis Genesis Sample header right hero section Image Background js layout Logo menu navigation Navigation Menu Nav Menu newsletter post page related posts responsive menu search search widget Shrinking Logo site header slide in-out Split Navigation Stylesheet Template Utility Bar Video Background widgets WordPress

Built with Genesis Framework + WordPress

  • Contact
  • FAQ
  • Disclaimer
  • Privacy Policy
  • Copyright Policy
  • Terms of Service