Created
October 15, 2016 17:32
-
-
Save AbhishekGhosh/562fe8764efe7d96645e75d410fbe20d to your computer and use it in GitHub Desktop.
AdSense WordPress PHP wp_is_mobile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( wp_is_mobile() ) { | |
echo '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> | |
<!-- your_unit_name --> | |
<ins class="adsbygoogle" | |
style="display:block" | |
data-ad-client="ca-pub-xxxxxxxxx" | |
data-ad-slot="xxxxxxxxx" | |
data-ad-format="auto"></ins> | |
<script> | |
(adsbygoogle = window.adsbygoogle || []).push({}); | |
</script>'; | |
}else if ( !wp_is_mobile() ) { | |
echo '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> | |
<!-- your_unit_name --> | |
<ins class="adsbygoogle" | |
style="display:block" | |
data-ad-client="ca-pub-xxxxxxxxx" | |
data-ad-slot="xxxxxxxxx" | |
data-ad-format="rectangle"></ins> | |
<script> | |
(adsbygoogle = window.adsbygoogle || []).push({}); | |
</script>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment