• I am working on looking for something that will allow me to put ads in my site that change per page load or change during the page (example: https://macthemes2.net/forum/) I am in need of putting them on my site, but i dont want ads everywhere, I will be selling these ad spots, and I DO NOT want to use Google Adsense. Anyone know any code or help with this issue? Thanks in advance!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Try a random or rotating ad plugin (there are several to choose from):

    https://www.ads-software.com/extend/plugins/

    Thread Starter themacfeed

    (@themacfeed)

    i cant seem to find any can you list a few, I have been on the plugins for hours.

    Thread Starter themacfeed

    (@themacfeed)

    I need some for the top under the navigation bar, not on the side…

    Try a Google search for randomizing or rotating ads for WordPress. Code to display random images or quotes could also be adapted to show ads.

    I am using this and I am happy with it (WP2.7.1) it’s not a plugin.

    Found a description here:
    https://www.tutorialized.com/view/tutorial/Creating-a-file-based-AD-rotator-script/24458

    Save your ad’s (images, jpg’s) in a folder on your server. Use Wordpad to make a file called adlist.txt .
    Example:

    <a target="_blank" href="https://2x2noppennieuws.nl"><img src="https://www.enduro.nl/sponsorpagina/logos/2x2nop.jpg" alt="2x2 NOPPENNIEUWS" border="0" /></a>
    <a target="_blank" href="https://www.andremotors.nl"><img border="0" src="https://www.enduro.nl/sponsorpagina/logos/ANDRE_MOTORS.jpg" alt="" /></a>

    Every ad gets one line; no line-breaks!!

    Save the follwing code as microADRotator.php in your theme folder:

    <?php
    // Function to display random ads from a list
    function showRandomAD($ADnumber = 1){
    // Loading the ad list into an array
    $adList = file('/var/www/vhosts/enduro.nl/httpdocs/sponsorpagina/logos/adlist.txt');
    
    // Check the total number of ads
    $numberOfADs = sizeof($adList);
    
    // Initialize the random generator
    list($usec, $sec) = explode(' ', microtime());
    srand((float) $sec + ((float) $usec * 100000));
    
    // Initialize the ads counter
    $adCount = 0;
    
    // Loop to display the requeste number of ads
    while ($adCount++ < $ADnumber) {
    // Generate random ad id
    $actAD = rand(0, $numberOfADs-1);
    // Display the above generated ad from the array
    echo $adList[$actAD].'';
    }
    }
    ?>

    Change line 5 to your situation, calling the adlist.txt

    Ad this to the very top of for example your rightsidebar:
    <?php require_once('microADRotator.php');?>
    Next put this in for example your rightsidebar, there where you want the ad (s) to appear. Change the number after showRandomAD to show 1 or 2 ad’s etc:

    <div id="adrotator">
        <?php showRandomAD(6); ?>
    </div>

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Ad that changes per-load, Need HELP!’ is closed to new replies.