Skip to content

Instantly share code, notes, and snippets.

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 heyitsritesh/edb187182f516c3f3cc7893a2bc3b7b9 to your computer and use it in GitHub Desktop.
Save heyitsritesh/edb187182f516c3f3cc7893a2bc3b7b9 to your computer and use it in GitHub Desktop.
Display AdSense Auto Ads Only On Specific Pages In WordPress | https://www.digitalkube.com/adsense-auto-ads-on-specific-pages-wordpress/
//*** Auto Ads on Single Posts ***//
add_action( 'wp_head', 'digitalkube_add_tracking_code' );
function digitalkube_add_tracking_code() {
if (is_single()) {
?>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-xxxxxxxxxxxxxxx",
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