• Resolved dr.tanzil

    (@drtanzil)


    Hi,
    How to use this Plugin outside WP loop? Tutorial shows guideline to create shortcode on function.php. How to call the plugin without shortcode, i mean with direct PHP call?

Viewing 1 replies (of 1 total)
  • Plugin Author iSaumya

    (@isaumya)

    Hi,
    Inside PHP it is even easier to call. Here is an example

    <?php 
    // lets say this is a template page
    // or whatever page, doesn't matter
    // you can directly do this:
    
    if( aicp_can_see_ads() ) {
    	// show ads to the users who are allowed to see
    	$adCode = '<div class="aicp"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- 300x250 Example Ad Code -->
    	<ins class="adsbygoogle"
    	style="display:inline-block;width:300px;height:250px"
    	data-ad-client="ca-pub-1234567890123456"
    	data-ad-slot="987654321123"></ins>
    	<script>
    	(adsbygoogle = window.adsbygoogle || []).push({});
    	</script></div>';
    	echo $adCode;
    } else {
    	// This segment is optional
    	// Show anything for users who are banned from seeing ads
    	echo '<div class="ad-banned">You cannot see anymore ads. Sorry!</div>';
    }
    
    ?>

    I hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘How to call plugin out side loop by PHP?’ is closed to new replies.