Practically, you can access most functions and methods used in Advanced Ads, but there are some especially designed to be used in your frontend and theme files.

You can find these functions in advanced-ads/includes/functions.php .

advads_can_display_ads()

Returns false if ads are disabled on the current page view.

get_ad($id)

Get content of the ad with the ad id

Example:

the_ad($id)

Echo the content of the ad with the ad id

Example:

get_ad_group($id);

Get the content of an ad from an ad group using the ad group id.

Example:

the_ad_group($id)

Echo the content of an ad from an ad group using the ad group id.

Example:

get_ad_placement($id);

Get the content of an ad from an ad placement using the placement id.

Example:

the_ad_placement($id)

Echo the content of an ad from an ad placement using the placement id.

Example:

group_has_ads($id)

Check if the group with the given ID has any ads that can currently show up.

placement_has_ads($id)

Check if the placement with the given ID has any ads that can currently show up.

check if placement has ads using JavaScript

When ads are not loaded using PHP, but our JavaScript-based cache-busting feature, you can use code like below to check if a placement is filled. This is just a mockup. Depending on when and where you load the code, you might use something like setInterval() to defer the check.

 

Additional attributes

You can use additional attributes when calling the functions to load an ad, group, or placement in order to override the options. This should be used by advanced developers only.

The attribute structure is derived from how options for ads, groups, or placements are stored. You should also notice the subarray change-ad, change-group, and change-placement depending on which level you would like to adjust.

The following example shows how to change the content of an ad and the top margin to 5 using $args in the get_ad function.

You can also override options of the ads within a group or placement. The following changes the item displayed through the placement and the content of all ads displayed through them.