Show adverts on your site

Difficulty: Intermediate | Updated: February 14, 2017

Showing adverts on your site is easy. But will require some planning and measuring. Adverts don’t fit everywhere because of some restrictions by themes. But also simply because the location is not suitable.

You can add adverts pretty much everywhere on your site with relative ease. The easiest method is to use widgets. Almost every theme supports widgets and some themes use them for page building also. This allows you a great deal of freedom where you place your adverts.
Another widely supported method is to use shortcodes. These are simple to use codes generated by AdRotate which you can place in your posts, pages and some text widgets.

Widgets

Being the most simple way to add adverts to a page this will be the preferred method for a lot of people. Simply drag the widget to the location you want it to show up, select if you’re showing a group or an advert and fill in the ID.

adrotate-widgets

Using Shortcodes

Shortcodes work on Pages, Posts and some widgets. Some themes also support shortcodes in their text widgets.

Examples:

Single advert:

[adrotate banner="12"]

A random advert from a group:

[adrotate group="2"]

Multiple groups and a random advert from either group:

[adrotate group="4,12,5,2"]

Group with optional fallback override (Group 7, fall back on group 19):

[adrotate group="7" fallback="19"]

Group with optional weight override (Group 23, show only adverts with weight 4 or higher):

[adrotate group="23" weight="4"]

Cross site ads on a Multisite with a Developer License:

[adrotate group="7" site="1"]
[adrotate banner="12" site="1"]

The cross site value is a switch, not an ID!

Using PHP code

Caution: For advanced users only!
Insert the following PHP code in index.php, page.php or single.php of your theme. Anywhere where you want the banner to show, as many as you like.
If you have custom templates or you now what you are doing you can insert the code in other files as well.

Examples:

Single advert:

echo adrotate_ad('1');

A random advert from a group:

echo adrotate_group('12');

Multiple groups and a random banner from either group:

echo adrotate_group('3,2,6');

Fallback override for a group (group 4, falls back on group 16):

echo adrotate_group('4', '16');

Weight override for a group (group 12, no fallback, show adverts with weight 8 or higher):

echo adrotate_group('12', '0', '8');

Cross site ads on a Multisite with a Developer License:

echo adrotate_group('4', '0', '0', '1');
echo adrotate_ad('4', true, '0', '0', '1');

Note: The cross site value is a switch, not an ID!