0

I am trying to place a javascript ad zone inside a php function. I am doing this to control what ad zones are placed on each page. Currently in the php template I am using:

<?php
        if(is_page('welcome-president')) {
            oiopub_banner_zone(9);
            oiopub_banner_zone(19);
        } 
        ?> 

I am trying to place this javascript code inside the if conditional tag instead of the oiopub_banner_zone(9); so that the ads will not be cached and rotate.

<script type="text/javascript" src="http://rutgers.myuvn.com/wp-content/plugins/oiopub-direct/js.php#type=banner&align=center&zone=9"></script>

Thanks in advance!

Tyler
  • 3
  • 3

2 Answers2

0

Rather than call the function oiopub_banner_zone(9) to display the banner code, you can just replace that function call with echo and the actual script tag that you would like to output on the page.

<?php
    if(is_page('welcome-president')) {
        echo '<script type="text/javascript" src="http://rutgers.myuvn.com/wp-content/plugins/oiopub-direct/js.php#type=banner&align=center&zone=9"></script>';
        oiopub_banner_zone(19);
    } 
?>
slapyo
  • 2,979
  • 1
  • 15
  • 24
  • 1
    While this snippet might fix the issue, it would be nice to describe your approach so that future readers, having a different but similar issue, benefit from it. – RandomSeed Oct 09 '14 at 17:51
  • Thanks for the reminder. I just added a description. – slapyo Oct 09 '14 at 17:53
  • Thanks, this has solved the problem while still allowing me to control the ad space manually. Thanks – Tyler Oct 09 '14 at 19:21
0

If you want to prevent caching. Make an that points to some place in your site ( e.g. /ad_iframe.php ) and do the rotate logic to retrieve the add content there. That will not get cached.

There was a post about it that helped me a lot.

Preventing iframe caching in browser

Good luck, and cheers.

Community
  • 1
  • 1
Celeb
  • 88
  • 4