Support » Plugins and Hacks » AdRotate » [Resolved] Reporting Ad Display Bug

[Resolved] Reporting Ad Display Bug

  • kirkvan


    I asked my WordPress programmer why there was a problem displaying ads at our HeartBeatOfKauai.com site, and he replied with:


    The issue is because of bug in the AdRotate plugin code.

    The plugin calculates the height of widget using the formula
    height = (no. of ad items / no. of columns) * (Adheight + padding)
    Since the no. of items is 5 (odd number) with 2 columns. it calculates the height as 2.5 times Adheight. Hence the last ad is close to half cut.

    I checked the plugin code and there isn’t any hook or filter to alter this without editing code.

    Solution 1: Change the no. of ads to even no.

    Solution 2: Remove the widget and add the Adblock widget code to sidebar so we get control over styling.

    Cannot use css because the adblock doesn’t have id attribute or class attribute.


    Seems there’s a third solution, which would be to have you fix your code. Please advise.


Viewing 10 replies - 1 through 10 (of 10 total)
  • kirkvan


    My programmer just added:

    Ad Units in block : 5 (each 125px square ad)
    Rows : 3
    Column : 2
    Block Padding : 0
    Ad Padding / Margin : both 5px
    Border: 0

    File: adrotate-output.php
    Line No: 296

    // determine grid size based on amount of ads
    $block_count = $block->columns * $block->rows;
    if($array_count < $block_count) $block_count = $array_count;

    // resize block in height
    if($block->rows > ($block_count / $block->rows)) $block->rows = $block_count / $block->columns;

    Line No: 318

    $gridheight = ($block->rows * $block->adheight) + $heightmargin.’px’;

    Calculations results:
    $array_count = 5
    $block_count = 2 x 3 = 6
    if(5 < 6) $block count = 5
    if(3 > (5 / 3)) $block->rows = 5 / 2 = 2.5

    Line No: 312

    $heightmargin = (($block->admargin * 2) * $block->rows) + (($block->adpadding * 2) * $block->rows) + (($adborder * 2) * $block->rows);
    $heightmargin = ((5 * 2) * 2.5) + ((5 * 2) * 2.5) + 0 = 50
    $gridheight = 2.5 * 125 + 50 = 362.5px

    The final output starts like this…
    <div style=”float:none;margin:0;padding:0px;clear:none;width:290px;height:362.5px;border:none;”>
    (so I assume the above calculation is correct)

    Plugin Author Arnan de Gans


    Or you just create a block of 6 ads (2 columns of 3). AdRotate will know and leave the 6th spot free if you have only 5 ads. But the sum is correct then.

    It makes no sense to have a 2 column 5 ad block.

    Assuming you mean this:

    if(5 < 6) $block count = 5
    if(3 > (5 / 3)) $block->rows = 5 / 2 = 2.5

    as a solution. Makes little sense either and would deform any block at any time. No matter how many ads you put in there. Since 5 *is* always lower than 6.



    Thanks Arnan de Gans for the reply. However we were unable to understand what you mean exactly.

    // It makes no sense to have a 2 column 5 ad block.
    We only have 5 Ads and we can fit only 2 ads/row in the sidebar. So we have 2 items/row and 3 columns to fit 5 Ads.
    We DO NOT have 6th Ad.
    How do we fit the 5 Ads we have in sidebar ??

    Ideally the plugin should take care of the rounding off part. ie. calculate the height for 6items instead of 5items.

    Any solution to solve this issue?

    Plugin Author Arnan de Gans


    Yes, use the original plugin and use even numbers for the block.

    If you want a block of 2 columns with 2 and 3 ads (5 total) create a 2×3 block (space for 6 ads). AdRotate will correct/anticipate the missing ad. As I said a in my previous post.

    @arnan, thanks for your replies. The Ad Block has always been 2 columns by 3 rows for six ads total, incorrectly display 5 ads. That’s why myself and Tamil opened this thread and reported the problem. Please advise.

    OK, we are now displaying five ads via AdRotate in the right-hand sidebar here:

    Ad Listings

    Do you now understand the display problem we initially reported and have been trying to explain over the course of this entire support thread?

    Please advise.

    HeartBeatOfKauai.com switched to 6 ads, but is now once again displaying 5. As I shared in my post of one week ago, you can now see the problem. Arnan de Gans, could you please take a look and reply?

    Plugin Author Arnan de Gans


    I rarely look here, for faster help go to my ticket support site – http://www.ajdg.net/support/.

    If the ads do not fit it’s a markup issue in your adcode or perhaps the sizing of the block is set wrongly (too few pixels for the ads for example).

    When I look in my Safari I see 6 ads.

    Thanks for your message. Yes, there are once again 6 ads running. Next time there are 5 ads, we’ll post at your support site: http://www.ajdg.net/support/

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] Reporting Ad Display Bug’ is closed to new replies.
Skip to toolbar