Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active March 16, 2018 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braddalton/e1bf8da5b4465ebeccf3db29ed4395c7 to your computer and use it in GitHub Desktop.
Save braddalton/e1bf8da5b4465ebeccf3db29ed4395c7 to your computer and use it in GitHub Desktop.
Adsense Auto Ads in Genesis - Conditionally Remove From Posts in Specific Category https://wp.me/p1lTu0-hoH
add_action( 'wp_head', 'adsense_auto_ads' );
function adsense_auto_ads() {
if ( ! is_singular(array( 'post','page' ) ) ) {
return;
}
if ( in_category( 'sponsored' ) ) {
return;
}
?>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-xxxxxxxxxxxxx",
enable_page_level_ads: true
});
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment