• Resolved chanfullstack

    (@chanfullstack)


    Hi there, I’m trying to create a custom function to hide placeholder ads (ads with a wrapper class of ad-placeholder) if a user bought an Ad through our dedicated buy ads form.

    I’m able to hide the placeholder ads by using advanced-ads-can-display filter hook. I’m checking if the current ad have the placeholder class and check all the ads within a group where the current ad belong. And if any of the ads within the group does not have the placeholder class, the function will return false to hide the current placeholder ad.

    The only problem here is that, I should not be checking against all ads within the group. I should only check the ads that are showing on the same page as the placeholder ad.

    Is there a way to know if an Ad can be displayed on the current page?

    I’ve tried using Advanced_Ads_Display_Conditions class methods. But after checking the plugin source code, I found out that these methods uses a post info from the ads’ options property. After checking, ads does not have the post data on the time the hook is called.

    What am I doing wrong here?
    Is there any other way to achieve what I’m trying to do?

    Any help would be greatly appreciated. Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi chanfullstack,

    Thanks for reaching out.

    I am correct that you want to sell an ad space and after purchasing the buyer should immediately see the purchased ad instead of the placeholder ads?

    I suggest using the build in feature of ordered ad groups here. If you have your placeholder ad assigned with the weight of 1 and add the sold ads with a weight of 10 the group will automatically show the higher weighted ad. This also comes handy if the ads run out due to their expiry date, the placeholder ad will show up automatically again.

    Please let me know if you need anything else.

    Best regards,
    Henning

    Thread Starter chanfullstack

    (@chanfullstack)

    Hi @henningaa,

    Thank you for the response.

    I got your point but does assigning a weight of 1 will hide the ad completely?

    Thank you again,
    Chan

    Hi Chan,

    Thanks for the question.

    The weight of 1 will ensure there is always a fallback ad to show if no sold ad is available.

    If you need to hide the ad space completely, leave the assigned ad group empty and no ad will show.

    Please let me know if this is close to the wanted behavior you have in mind, or if I am missing something.

    Best regards,
    Henning

    Thread Starter chanfullstack

    (@chanfullstack)

    Hi @henningaa,

    Thank you for the clarification.

    I will try the approach you gave.

    Btw, regarding hiding the ad space, we are not doing that yet but thank you for the heads up.

    You’re awesome!

    Best regards,
    Chan

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Manually check if an Ad can be displayed on a page.’ is closed to new replies.