Ad Rotator

Posted by Dmytro Shteflyuk on · Русский (255,583 views)

Ad Rotator is a simple WordPress widget to display random HTML code from a given group of HTML-chunks separated with <!--more--> on sidebar. Basically it shows different HTML every time you requesting page. There are infinite number of instances of this widget may exist.


  1. Download and unpack plugin files to wp-content/plugins/ad-rotator/ directory.

  2. Enable Ad Rotator plugin on your Plugins page in Site Admin.

  3. Go to the Appearence/Widgets page in Site Admin and drag as many Ad Rotator widgets to your sidebars as you wish. Configure instances separating HTML blocks with <!--more-->. Save changes.

    Ad Rotator widget configuration

    Sidebar with Ad Rotator widgets

  4. Now on Ad Rotator blocks should appear on your sidebars.

Migrating from AdRotator plugin

AdRotator plugin is a simple file-based ad rotation solution. It was developed by Angsuman Chakraborty long time ago, but occasionally we have the same plugin names from WordPress’ point of view. If you are using this plugin, you may click upgrade link from your Plugins page and it being replaced with Ad Rotator widget.

So now you have two ways to solve the problem 'getad()' function is undefined:

  1. You can download AdRotator and ignore upgrade notices, or

  2. You can upgrade your theme to use Ad Rotator Widget.

Here is how to upgrade your theme. Find all occurrences of getad function,
and replace them with something like this:

  'name' => 'ad-area',
  'id' => 'ad-area',
  'before_widget' => '',
  'after_widget' => '',
  'before_title' => '',
  'after_title' => ''

Make sure you’ve replaced ad-area with the name suitable for you. Also
you can specify additional options, like before_title and after_title.

Then open the Appearence/Widgets page in Site Admin and configure Ad Rotator widget instances for your advertisements area. Just take into account, that in files for AdRotator ads are separated with new line character (ie each line means separate ad), but in Ad Rotator widget you should separate you blocks with <!--more--> (so each of them may contain more then one line.)

Anyways, sorry for сonfusion, I did not want to сheat on you.


Plugin requires the WordPress version 2.8.0. Be sure your theme supports sidebar widgets.


Latest version of “Ad Rotator” is 2.0.3, and it can be downloaded here:

version2.0.3DownloadAd Rotator

If you have any propositions, want to send feedback or found bugs, please post comments. It’s very important for me!

Frequently Asked Questions

Q. How to enter several ads to a single text box?
A. Separate your ad blocks with <!--more--> sequence.

Q. How many ads every instance of widget could handle?
A. Number of advertisements in each instance is unlimited.

Q. Can I use Google AdSense code as one of my ads?
A. Of course, you can use any HTML you wish (AdSense, Clicksor, Chitika, and everything else).

Q. WordPress shows `’getad()’ function is undefined` error
A. See explanation in Migrating from AdRotator plugin section.


  • 2.0.3 (July 30, 2009)
    • Fixed problem with backslashes appearing inside HTML (thanks to Maxx Kremer).
  • 2.0.2 (July 29, 2009)
    • Added section Migrating from AdRotator plugin in readme.txt.
  • 2.0.1 (July 29, 2009)
    • Fixed Installation section in readme.txt.
    • Filter out HTML when user has no rights to edit unfiltered HTML.
  • 2.0.0 (July 29, 2009)
    • Completely rewritten using new WordPress 2.8 widgets API.
    • Readme.txt file and couple of screenshots added.
  • 1.0.1 (March 31, 2007)
    • Plugin home page updated.
  • 1.0.0 (May 1, 2006)
    • Initial plugin implementation.

Other plugins

Full list of plugins I have implemented is available here.

91 Responses to this entry

Subscribe to comments with RSS or TrackBack to 'Ad Rotator'.

said on May 12, 2009 at 11:33 pm · Permalink · Reply

Hi. is there soemthing wrong witht he plugin?

After installing it wont let me activate it. is the version still compatible. im using wordpress 2.7.

I made this web site. It’s all about celebrity news and gossip…So I’d appreciate your opinion on web site, this ad widget sounds cool.

said on May 19, 2009 at 7:28 am · Permalink · Reply

I’m getting the same “Fatal error: Cannot use string offset as an array” problem as Mimi above. It happens when I try to go to my “Widgets” page in wp-admin. It used to work fine, now it doesn’t. I tried erasing the data in Mysql but it didn’t work. Suggestions please? It was such a useful plugin.

said on June 18, 2009 at 7:14 am · Permalink · Reply

I did a fresh install of wordpress 2.8 and when I go to add more ad-rotator widgets it won’t add anymore than just one. Any ideas on a quick fix?


Stacie @
said on June 27, 2009 at 2:03 am · Permalink · Reply

Right now I have 3 ad rotator widgets that are all working fairly well however, I want more. I have tried to request more using the “how many do you want” option but no matter how many I choose none appear. What am I doing wrong?

Jason Rogers
said on July 3, 2009 at 7:44 am · Permalink · Reply

This widget doesn’t work in multi-mode in wp2.8 anymore, as they have changed the way widgets are created and coded from 2.8 and on:

Might want to update it and maybe, just maybe submit it to the WordPress Plugin database so we can find the updated version on there too… it would be a waste if you didn’t and left the widget here to die.

Steve @
said on July 10, 2009 at 1:10 pm · Permalink · Reply

Prior to upgrading to WordPress 2.8, Ad Rotator had the option to select multiple instances of the plugin. Now the selection for multiple instances is still there but no additional Ad Rotators appear after choosing a number of extra copies. Is this something that can be tweaked in the plugin to make it compatible or is this a bug to be pursued at

Steve @
said on July 19, 2009 at 5:49 pm · Permalink · Reply

Hello?? Is this plugin going to be upgraded to work in multi-mode?

said on July 29, 2009 at 10:22 pm · Permalink · Reply

Um.. I ran into that WP upgrade error because I am using the real AdRotator. You should change the name so your widget doesn’t do that.

said on July 30, 2009 at 1:09 am · Permalink · Reply

Cole, I’m not sure that this is the best solution. This widget is more than 3 years old, so it has his own users, and I am not ready to stop providing them a good solution for this day-to-day problem.

Maxx @
said on July 30, 2009 at 1:16 am · Permalink · Reply

Hi Dmytro,

Thanks for updating the plugin. This is a great plugin that I would be lost without!

Kudos to you!

Ike @
said on July 30, 2009 at 6:31 am · Permalink · Reply

I’m having an issue since the upgrade — backslashes are now appearing before all of my double-quotes and apostrophes.

Look in my sidebar under “Rave Reviews” to see what I mean.

Steve @
said on July 30, 2009 at 8:31 am · Permalink · Reply

Where is 2.0.3? I just downloaded the plugin and it appears to still be 2.0.2 and still the same issue with backslashes.

Steve @
said on July 30, 2009 at 4:26 pm · Permalink · Reply

Thanks Dmytro! Greatly appreciated. Where is your PayPal donation link?

Dave @
said on July 31, 2009 at 12:03 am · Permalink · Reply


Is there any way to stop the plugin from trying to escape quotes when you add some html? I am trying to add a banner image withing a link and it doesn’t show up because the plugin automatically escapes the quotes.


said on July 31, 2009 at 4:00 am · Permalink · Reply

How do I have the rotating ads show up in my Theme? I did not understand the directions. I created a TXT file with the HTML for images and links, and uploaded it to the wp-content folder. Is this method still used with this new version?

Stacie @
said on August 3, 2009 at 6:56 am · Permalink · Reply

I just updated and I’ve had a few issues. First, the update essentially deleted all my existing rotators. Luckily I was planning on changing the ads anyway. Now, as I’m starting over, the rotators are showing multiple ads stacked on each other with (!–more–) between them.

said on August 8, 2009 at 9:52 am · Permalink · Reply

Hi Dmytro, I must be pretty thick!!…I have finally been able to get the first image to appear, but the images won’t rotate. Can you please take a look at the code below and tell me what I am doing wrong? Thanks, Steve


said on August 8, 2009 at 10:03 am · Permalink · Reply

I have changed my code since last post as the images were all running in-line down the column…current code looks like this, but still no rotating…Regards, Steve


said on August 15, 2009 at 5:19 am · Permalink · Reply

Can I enter another web site widget code into the rotator? I’d like to enter widgets like weather and stuff and have them rotate. Thanks.

said on August 27, 2009 at 8:41 am · Permalink · Reply

I’m getting this error when I try to activate the plugin:

Fatal error: Class ‘WP_Widget’ not found in /zine/wp-content/plugins/ad-rotator/adrotator.php on line 28

How might I go about fixing it?

said on August 27, 2009 at 10:26 am · Permalink · Reply

Looks like you are using outdated WordPress version. You should update it to at least 2.8.0 to use this plugin. And I think you should do the upgrade, because there are many known security holes in old version, and your blog could be hacked by someone.

said on August 31, 2009 at 4:44 am · Permalink · Reply

I’m using this plugin in all of my websites.. The beauty is this will decrease down the ad blindness and users tends to click more on ads..More over other benifit is I can keep track of CTR and check which ad is performing well and remove the non performer..
My Kudos to this pligin

Dave @
said on September 23, 2009 at 2:46 pm · Permalink · Reply

I installed this plugin this morning because I was being prompted to upgrade from the old Ad Rotator plugin at
This plugin appears to do exactly what that one had done. The only difference between the two is that this one works in a widget whereas the old one worked with a template tag. I had gotten around the template tag issue when widgets were introduced by writing my own widget for the old plugin so I essentially had the same functionality on my website before I installed this one. And I have not had to update it for different WordPress versions (while this one seems to need updating occasionally). I’ll use this one for a while to see if there’s any real benefit to it but will probably switch back after a while.

And FYI – if you’re running the old version and want to keep it without getting prompted to upgrade to this one simply change the filename of the old one.

said on October 11, 2009 at 7:33 pm · Permalink · Reply

Having two plugins with the same name is bad enough, but making one rewriting over the other is very ugly thing in life. Having to redownload and reinstall the old one just because you thing widgets are nice is not appreciated.

said on November 7, 2009 at 7:40 pm · Permalink · Reply

[...] you find another theme that doesn’t include adsense, I’d recommend checking out the Ad Rotator. I haven’t tried it out, but it is supposed to be able to include ads into any WordPress [...]

More comments: 1 2 3

Post a comment

You can use simple HTML-formatting tags (like <a>, <strong>, <em>, <ul>, <blockquote>, and other). To format your code sample use [cc lang="php"]$a = "hello";[/cc] (allowed languages are ruby, php, yaml, html, csharp, javascript). Also you can use [cc][/cc] block and its syntax would not be highlighted.

Submit Comment