Skip to content

Instantly share code, notes, and snippets.

@idavinder
Last active December 22, 2015 15:49
Show Gist options
  • Save idavinder/6495516 to your computer and use it in GitHub Desktop.
Save idavinder/6495516 to your computer and use it in GitHub Desktop.
Disable Adsense on specific posts in WordPress
//add this to header.php file, also change 82959, 82960 post ids or add more in the code
//http://www.basicwp.com/block-adsense-ads-on-specific-posts/
<?php Global $ad_flg; $ad_flg=1; ?>
<?php $adsense_blck_post = array(82959, 82960); ?>
<?php if (in_array($post->ID,$adsense_blck_post,true)) $ad_flg=0; ?>
//add this on single.php where adsense ad is displayed
<?php Global $ad_flg; if($ad_flg!=0) { ?>
You adsense code here
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment