• Resolved countrymedia

    (@countrymedia)


    Hello, I am about to implement this plugin on my site, but can I put more than one shortcode inside the functions.php file and have it work correctly?

    I need to place code for BOTH 300 x250 ads and Responsive ads on my site…

    Thanks,

    Erik Utterback

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author iSaumya

    (@isaumya)

    Hi,
    you can create as many shortcodes you want just make sure each shortcode has different name.

    Thread Starter countrymedia

    (@countrymedia)

    Ok, would I need to have a blank line between the separate shortcode instances, like this?

    add_shortcode( ‘googlead1’, function() {
    if( aicp_can_see_ads() ) { // This part will show ads to your non-banned visitors
    $adCode = ‘<div class=”aicp”><!– Don\’t forget to add this div with aicp class –>
    <div class=”aicp”><script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
    <!– Google ROS ATF Medrec –>
    <ins class=”adsbygoogle”
    style=”display:inline-block;width:300px;height:250px”
    data-ad-client=”ca-pub-12345689123456789″
    data-ad-slot=”123456789″>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script> */ }
    </div><!– end of the aicp div –>’;
    return $adCode;
    } else { // Anything within this part will be shown to your banned visitors or to the blocked country visitors
    return ‘<div class=”error”>You have been blocked from seeing ads.</div>’;
    }
    } );

    add_shortcode( ‘googlead2’, function() {
    if( aicp_can_see_ads() ) { // This part will show ads to your non-banned visitors
    $adCode = ‘<div class=”aicp”><!– Don\’t forget to add this div with aicp class –>
    <script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script&gt;
    <!– AdSense Responsive Ad Code –>
    <ins class=”adsbygoogle”
    style=”display:block”
    data-ad-client=”ca-pub-1234567890″
    data-ad-slot=”0987654321″
    data-ad-format=”auto”>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    </div><!– end of the aicp div –>’;
    return $adCode;
    } else { // Anything within this part will be shown to your banned visitors or to the blocked country visitors
    return ‘<div class=”error”>You have been blocked from seeing ads.</div>’;
    }
    } );

    Plugin Author iSaumya

    (@isaumya)

    Yes you need to have a blank line in between like you have but in your first ad code at the end of </script> tag there is this */ } which I think there by mistake. Remove that or else that will give you an error.

    Thread Starter countrymedia

    (@countrymedia)

    Thanks! I will fix that up before enabling it later this week.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can I use multiple shortcodes?’ is closed to new replies.