Paid Memberships Pro AdSense Placement?

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?

1 Comment
  1. 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.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer