Show adverts on your site

Difficulty: Intermediate | Updated: July 13, 2020

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.


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.


Using Shortcodes

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


Single advert:

[adrotate banner="12"]

Single inline advert (This advert has its wrapper div stripped):

[adrotate banner="4" wrapper="no"]

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="yes"]
[adrotate banner="12" site="yes"]

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.


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', array('fallback' => '16'));

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

echo adrotate_group('12', array('weight' => '8'));

Cross site ads on a Multisite with a Developer License:

echo adrotate_group('4', array('site' => 'yes'));
echo adrotate_ad('4', array('site' => 'yes', 'wrapper' => 'no'));

Back to AdRotate Manuals

You may be interested in