Shortcodes

Advanced Ads provides shortcodes for each ad, group, and placement to be added to the content of pages manually.

Shortcode for ads

You can find the shortcode for an individual ad below the ad’s title on the edit page.

Shortcode of an ad unit from Advanced Ads
Find the shortcode below the title of your ad unit

The shortcode for single ads looks like below, with 648 being the individual ad ID.

[the_ad id="648"] 

Textlinks

If you include an ad inside a text using a shortcode and notice that a line break follows the ad, you can resolve this problem by changing div to span. To do that, add the inline parameter to your shortcode to avoid these line breaks:

 [the_ad id="648" inline="1"]  

Showing all shortcodes in the ad list

If you want to show all shortcodes in the ad list in the backend:

  • Go to Advanced Ads > Ads
  • Open the Screen Options at the top right of the screen
  • Enable Ad Shortcode in the Columns options

Shortcode for groups

You can find the shortcode for a group when you click on Usage below the group title on the group list.

shortcode for an ad group

The shortcode for a single group looks like below, with 5 being the ID of the group.

[the_ad_group id="5"]

Shortcode for placements

Only the Manual placements have shortcodes. You can find the shortcode when you click on show usage below the placement title.

Shortcode for the manual placement of Advanced Ads

The shortcode for a single placement does contain the name instead of a number as an ID. In the below example, it is custom-placement.

[the_ad_placement id="custom-placement"]

Shortcodes for ad impressions and clicks

To showcase the count of ad impressions or clicks in the frontend recorded by the Tracking add-on, utilize the following shortcodes.

[the_ad_impressions id="AD_ID"]
[the_ad_clicks id="AD_ID"]

Replace AD_ID with the ID of the ad.

Overriding attributes in shortcodes

You can override most options in a shortcode. You can also override attributes of ads via the group shortcode or a placement.

The logic uses the prefix change-ad, change-group, or change-placement and double underscores to separate options in arrays. 

To find the correct option to change, take a look at the source code. This is why this feature is only meant for advanced developers.

There are some options that you can’t adjust:

  • Cache Busting settings
  • target URL with click tracking

Examples

How to change the content of an ad and the top margin.

[the_ad id="123" change-ad__content="ad content" change-ad__output__margin__top="5"]

Adjusting how many ads are displayed simultaneously for a group and the top margin of the ads showing up.

[the_ad_group id="14" change-group__ad_count="2" change-ad__output__margin__top="5"]

Changing the element displayed through a placement and the ad’s content.

[the_ad_placement id="bc" change-placement__item="ad_211" change-ad__content="ad content"]

Using shortcodes from another blog in a multisite

With Advanced Ads Pro, you can also use the blog_id attribute on multisites to load an ad from another blog in the network.

The shortcode loads the ad with the ID 123 from blog 1 and can be used on every other blog in the multisite network where Advanced Ads and Advanced Ads Pro are activated.

[the_ad id="123" blog_id="1"]

Subscribe to our newsletter and get 2 add-ons for free!

* indicates required

Troubleshooting

Shortcode is visible in the frontend

Shortcodes are a WordPress standard. However, it is up to each plugin and theme to interpret them in their options. E.g., a theme might come with an option to add code to a certain position on the page, but not interpret shortcodes entered in it.

If you notice that only the shortcode string appears, but not the respective ad, group, or placement in its place, the missing shortcode support is probably the cause. In this case, the Custom Position placement is a good alternative.

Alternatively, you can contact your theme’s support and ask them to enable shortcodes for their options.

Make it better

Increase your ad management skills without spending more time.
Join over 150,000 publishers and AdOpts increasing their ad revenue.