WordPress.org

Forums

AdRotate
[resolved] [closed] How to check whether an ad is empty or not? (4 posts)

  1. Mayeenul Islam
    Member
    Posted 10 months ago #

    My site's ad places are like:

    <div class="ad">
    <?php echo adrotate_ad(1); ?>
    </div>

    If the ad is inactive the div.ad still loads and take its place there. So I want to check whether it's isset or not:

    <?php if( adrotate_ad(1) !== '' ) {
       <div class="ad">
          <?php echo adrotate_ad(1); ?>
       </div>
    <?php } ?>

    But you know it won't work as your inactive ads are passing the following text:

    <!-- Error, Ad is not available at this time due to schedule/geolocation restrictions! -->

    I want some ad to be inactive, and in that case don't want to load that assigned div. How can I do that for inactive ad?

    Or, can I check whether an ad is active or inactive?

    https://wordpress.org/plugins/adrotate/

  2. Arnan de Gans
    Member
    Plugin Author

    Posted 10 months ago #

    Try putting the div inside the ad or in the group wrapper ;)
    But if something is up, it will always output the error/warning and thus the div.

    AdRotate doesn't assume or cater for empty spaces. Neither should you.

  3. Mayeenul Islam
    Member
    Posted 10 months ago #

    So, adrotate doesn't doesn't have any checker whether the ad is active/inactive.
    Not solved, but forcefully solved. :(

  4. Arnan de Gans
    Member
    Plugin Author

    Posted 10 months ago #

    Of course there is a mechanism to check if an advert is active or not. That's an entirely different thing.

    You want to check if the ad is expired or not and depending on that show a div. That's not available as AdRotate handles that internally.

    So yes, this topic is solved as what you want to do is not available.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic