Created
February 2, 2017 10:42
-
-
Save isaumya/6945085c4405b37eed9c40bca206cb79 to your computer and use it in GitHub Desktop.
Example code of using AICP WordPress plugin directly inside your WordPress theme code
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>Some Page</title> | |
<link rel="stylesheet" href=""> | |
</head> | |
<body> | |
<?php | |
//Showing up the ad code at the start of body | |
if( aicp_can_see_ads() ) : // This part will show ads to your non-banned visitors | |
?> | |
<div class="aicp"><!-- Don\'t forget to add this div with aicp class --> | |
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> | |
<!-- AdSense Responsive Ad Code --> | |
<ins class="adsbygoogle" | |
style="display:block" | |
data-ad-client="ca-pub-1234567890" | |
data-ad-slot="0987654321" | |
data-ad-format="auto"></ins> | |
<script> | |
(adsbygoogle = window.adsbygoogle || []).push({}); | |
</script> | |
</div><!-- end of the aicp div --> | |
<?php | |
// Put this else block only if you wanna show something to users who have been blocked from seeing ads | |
// Otherwise you can just remove the else part and the echo below it and keep just the endif part | |
else : | |
// Anything within this part will be shown to your banned visitors or to the blocked country visitors | |
echo '<div class="error">You have been blocked from seeing ads.</div>'; | |
endif; | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment