Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.