Hello,
Paid Membership Pro says, Ad Codes should be placed within this tag:
if ( function_exists( ‘pmpro_displayAds’ ) && pmpro_displayAds() ) {
//insert ad code here
}
so my Could would be:
if ( function_exists( ‘pmpro_displayAds’ ) && pmpro_displayAds() ) {
<script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxx” crossorigin=”anonymous”></script>
}
but that isn’t accepted, “unsuscpected <”
so i found, that it should be done this way:
if ( function_exists( ‘pmpro_displayAds’ ) && pmpro_displayAds() ) {
echo”<script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxx” crossorigin=”anonymous”></script>”;
}
But that doesn’t work too, i get this error:
**syntax error, unexpected ‘https’ (T\_STRING), expecting ‘;’ or ‘,’**
Have you guys any idea on how to archieve that?
[ad_2]
Your answer is almost there. Try this,
if ( function_exists( ‘pmpro_displayAds’ ) && pmpro_displayAds() ) {
echo ‘<script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-xxx” crossorigin=”anonymous”></script>’;
}
the difference is I used ‘ instead of ” to wrap the script tag. You can’t put a ” inside of a “” because PHP thinks you are ending the string.