DEVELOPER GUIDES

Cookie consent for WordPress

The code goes into <head> before other scripts. A child theme is the most reliable — it survives theme updates.

Child theme — functions.php
add_action( 'wp_head', function () { ?> <script id="CookieFood" src="https://cookiefood.b-cdn.net/v1/consent.js" data-cfid="YOUR-ID" data-blockingmode="auto"></script> <?php }, 1 ); // priority 1 = as high in <head> as possible
Without touching code
Use a plugin like "Insert Headers and Footers" → Header section → paste the same <script> tag. Make sure it sits above other scripts.

What to watch out for

Priority 1 in add_action

Without it the script lands after Analytics and Pixel, which then fire first.

Purge your cache plugin

After deploying, clear the cache or visitors get a cached page without the banner.

Do not run a second consent plugin

Two banners overwrite each other’s consent records.

Where to get your YOUR-ID

Sign up, add a domain and you get the ID right away — the scan starts by itself. The snippet never changes again; everything else is configured in your account.

Other environments