Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What would be the best way to build an Ad rotator similar to those we usually see around from for example.

WordPress have a plugin/widget for adding ads:

Basically it shows random HTML code every time you refresh the page.

I was wondering how we can do that with Craft.

share|improve this question

You build this in a couple different ways but the simplest would be to setup ads as as channel with an asset for the add, url etc. In the template you could set the ad [the entry] to appear randomly by using shuffle().

If you're open to a paid solution we've got Ad Wizard up for sale on Craft Plus which might work for you as well.

share|improve this answer
Ahh, awesome: shuffle(). Thanks Adam! – Hafa Aug 18 '14 at 5:10

I built a plugin which does exactly this... Ad Wizard, which can be found on Craft Plus.

You can put your ads into groups, and add that group to your template like this:

{{ craft.adWizard.position('rightSidebar') }}

That code will automatically display a random ad from the group (unless it's disabled, expired, or over its maximum allowed impressions).

You can also target a single ad specifically, by referring to its ID number:

{{ }}

The plugin also gives you built in ad tracking... You can add two chart widgets to your dashboard which will show you statistics on how your ads are doing.

If you need any help, feel free to contact All feedback, bug reports, and feature requests are welcome!

share|improve this answer
Thanks Lindsey, I'll have a look at your plugin! :) – Hafa Aug 18 '14 at 5:06
Great! Feel free to contact me with any feedback or issues. :) – Lindsey D Aug 18 '14 at 5:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.