Skip to content

Instantly share code, notes, and snippets.

@henshaw
Last active September 29, 2021 03:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save henshaw/1f7857b785672604026d42470afa463e to your computer and use it in GitHub Desktop.
Save henshaw/1f7857b785672604026d42470afa463e to your computer and use it in GitHub Desktop.
Block FLoC in WordPress
// Disable FLoC
function disable_floc($headers) {
$headers['Permissions-Policy'] = 'interest-cohort=()';
return $headers;
}
add_filter('wp_headers', 'disable_floc');
@henshaw
Copy link
Author

henshaw commented Apr 18, 2021

From Opting your Website out of Google's FLoC Network

WordPress allows headers to be set from within its codebase via hooks. Add the code at the end of your active theme’s functions.php file.

Save the file in the WordPress admin backend and all new requests will contain the necessary header.

If you’re using any caching mechanisms or plugins (such as NGINX’s FastCGI Cache, W3 Total Cache, etc.) you’ll also need to clear the cache so that it be re-populated with the above addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment