Short Codes

Guide Menu ×

AdSanity ads or ad groups can be added to pages or posts via short codes.

There are two convenient short code builders available on the visual tab of the page editor (fig. 1). The Insert Ad tool allows you to place a single ad from your list of advertisements. The Insert Ad Group tool allows you to place an ad group and even gives you the options to show multiple ads from the group and set the number of columns they are to be displayed in (fig. 2).

fig. 1 – The short code tools
fig. 2 – The Ad Group short code tool

In addition, you can click a link to copy the short codes from the Manage Ads page, individual ad pages, or from the Ad Groups page.

Short Code Reference

One of the methods of placing ads on pages that AdSanity supports is via short codes. We provide short code builders for single ads and ad groups in the core AdSanity plugin. Additionally, shortcode builders are added to the classic WordPress editor when you install the Ordered Ad Group Widget Add-On and the Rotating Ad Widget Add-On. These builders allow you to quickly add the short code to your pages. However, you may want to add your short codes manually and this reference breaks down the attributes in each of the short codes.

Single Ad Short Code

The single ad short code consists of three parameters; id, align, and max_width (which is optional).

Example [adsanity id="107" align="alignleft" max_width="100"/]

  • The adsanity id parameter has a value equal to the id number of the ad in use.
  • The align parameter can have values of; alignleft, alignright, aligncenter, or alignnone.
  • The max_width parameter has a value equal to the pixel width you enter.
Ad Group Short Code

The ad group short code has six parameters; num_ads, align, num_columns, group_ids, and max_width (which is optional). Note: displaying a single random ad from a group is as simple as setting your num_ads and num_columns parameters to 1.

Example [adsanity_group num_ads="1" align="alignleft" num_columns="1" group_ids="2" max_width="100" random="1"/]

  • The adsanity_group num_ads parameter has a value equal to the number of ads in the group you want to display.
  • The align parameter can have values of; alignleft, alignright, aligncenter, or alignnone.
  • The num_columns parameter has a value equal to the number of columns you specify.
  • The group_ids parameter has a value equal to the id number of the ad group in use.
  • The max_width parameter has a value equal to the pixel width you enter.
  • The random parameter has a value of 1 (for randomized) or 0 (for no randomization).
Rotating Ad Short Code

The rotating ad short code has five parameters; align, time, group_id, and max_width (which is optional).

Example [adsanity_rotating align="alignleft" time="10" group_id="2" max_width="100" random="1"/]

  • The adsanity_rotating align parameter can have values of; alignleft, alignright,aligncenter, or alignnone.
  • The time parameter has a value equal to the rotation interval you specify in seconds.
  • The group_id parameter has a value equal to the id number of the ad group in use.
  • The max_width parameter has a value equal to the pixel width you enter.
  • The random parameter has a value of 1 (for randomized) or 0 (for no randomization).
Ordered Ad Group Short Code

The order ad group short code has four parameters; ad_ids, num_columns, align, and max_width (which is optional).

Example [adsanity_ordered ad_ids="105,107,104,106" num_columns="1" align="alignleft" max_width="200" /]

  • The adsanity_ordered ad_ids consists of the ad ids in the order you want them to appear separated by commas.
  • The num_columns parameter has a value equal to the number of columns you specify.
  • The align parameter can have values of; alignleft, alignright, aligncenter, or alignnone.
  • The max_width parameter has a value equal to the pixel width you enter.

Short Code Reference