Forums

Ad that changes per-load, Need HELP! (7 posts)

  1. TheMacFeed
    Member
    Posted 2 years ago #

    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: http://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!

  2. iridiax
    Member
    Posted 2 years ago #

    Try a random or rotating ad plugin (there are several to choose from):

    http://wordpress.org/extend/plugins/

  3. TheMacFeed
    Member
    Posted 2 years ago #

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

  4. iridiax
    Member
    Posted 2 years ago #

  5. TheMacFeed
    Member
    Posted 2 years ago #

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

  6. iridiax
    Member
    Posted 2 years ago #

    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.

  7. henkholland
    Member
    Posted 2 years ago #

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

    Found a description here:
    http://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="http://2x2noppennieuws.nl"><img src="http://www.enduro.nl/sponsorpagina/logos/2x2nop.jpg" alt="2x2 NOPPENNIEUWS" border="0" /></a>
    <a target="_blank" href="http://www.andremotors.nl"><img border="0" src="http://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>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.