Ad Rotator

Posted by Dmytro Shteflyuk on

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.

Installation

  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:

1
2
3
4
5
6
7
8
register_sidebar(array(
  '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.

Requirements

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

Download

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.

Changelog

  • 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.

95 Responses to this entry

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

said on April 12th, 2007 at 15:37 · Permalink · Reply

my site admin in 2.1 does not have a presentation/sidebar widgets section, and this plugin pushes the sidebar out of alignment

said on April 12th, 2007 at 17:01 · Permalink · Reply

Looks like your theme does not supports widgets at all. In this case Ad Rotator is used and can’t break down your sidebar alignment.

said on April 13th, 2007 at 00:08 · Permalink · Reply

Is there a way to force the change of ad on every refresh?

said on April 13th, 2007 at 00:51 · Permalink · Reply

Random block is shown on each request. It’s possible that sometimes ad would be repeated, but usually random HTML would be displayed.

said on April 16th, 2007 at 12:30 · Permalink · Reply

Thanks for this. It works well aside from a small problem I’m having where sometimes I get a blank space where the ad should be.

I’m wondering if I’m doing something wrong or if it’s some kind of timing problem. Should the <!--more--> delimiter only appear after the code chunks?

Any ideas?

Thanks

Gary

said on April 16th, 2007 at 13:41 · Permalink · Reply

It should appear between code chunks. It is just divider and separates chunks between each other. Therefor if you would past it after all chunks, blank area would be displayed sometimes because Ad Rotator would think that another chunk exists after last one. Just for example:

1
2
3
<img src="ad1.jpg" />
<!--more-->
<img src="ad2.jpg" />

This is correct using of plugin. And here is another wrong one:

1
2
3
4
<img src="ad1.jpg" />
<!--more-->
<img src="ad2.jpg" />
<!--more-->

In the first case you have two chunks, in the second case there are three chunks exists, and one of them is blank.

JR
said on May 18th, 2007 at 13:33 · Permalink · Reply

Hi,
is this widget supporting <code> tags?

I am trying to steer it to my wordpress theme directory using <code></code>

Cheers

Casey V.
said on May 28th, 2007 at 07:52 · Permalink · Reply

I was wondering how to add additional Ad Rotator widgets to my sidebar?

Casey V.
said on May 28th, 2007 at 08:30 · Permalink · Reply

Wow never mind. Guess I should have scrolled down a bit :)

said on June 8th, 2007 at 21:59 · Permalink · Reply

For some reason, this code:
<a href=”http://www.noliberties.com/” target=”_blank”><img src=”http://www.noliberties.com/img/banners/tl_skyscraper.jpg” alt=”Taking Liberties” width=”160″ height=”600″ border=”0″ /></a>

is being rendered as

<div class=”adrotatorwidget”><a href=”http://www.noliberties.com/”><!– –></a></div>
</li>

by both this and the text box plugin. It’s driving me crazy… and so am removing the widget for now.

Any idea? As it seems insane not to be able to easily display arbitrary html snippets!

Thanks.

lex
said on June 15th, 2007 at 20:19 · Permalink · Reply

Dmytro,

AdRotator was working great for me until I “upgraded” to WP2.2 – now my (paid for) content isn’t showing up, even though the proper html is in AdRotator boxes.

Has anyone else mentioned this?

lex
said on June 15th, 2007 at 20:51 · Permalink · Reply

It turns out that whatever html is in AdRotator Widget #1 is displayed on every other widget even if the html they contain are different…

said on June 25th, 2007 at 21:55 · Permalink · Reply

I’ve used this fantastic widget/plugin for a few weeks and it works great.

However, Fantastico recommended that I upgrade my WordPress install from 2.1.3 to 2.2, and when I did the Ad Rotator instances that I have running in my sidebar turned into duplicates. So, instead of running Ad Rotator Widgets 1, 2, and 3. It just displays the content for Ad Rotator Widget 1 three different times.

Anyone else run into this?

Thanks!
Josh

lex
said on June 29th, 2007 at 13:23 · Permalink · Reply

It was a known problem with the widgets.php apparently. You can download and replace the file here

said on July 20th, 2007 at 02:08 · Permalink · Reply

I am working with a fresh install of WordPress 2.2 (about a week old) and I just installed Adrotator. It installed fine and I put the widget in the sidebar but the title is the only thing that appears. In Firefox, I get nothing at all and in IE I get a broken link symbol. I tried downloading that new widgets.php file, but it didn’t change anything. Any other suggestions?

said on August 3rd, 2007 at 02:23 · Permalink · Reply

Hello,

I want to confirm that all code chunks as described below go in the function widget_adrotator_control($number) section.

Following that, the next step is to insert the code add_action(‘plugins_loaded’, ‘widget_adrotator_init’);
to the sidebar and then paste the adrotator code to the correct section of the sidebar.

I hope this makes some sense.

said on September 16th, 2007 at 07:59 · Permalink · Reply

Can anyone tell me why the limit is 9 ad rotator widgets?

Any way of upping that limit?

said on September 27th, 2007 at 02:06 · Permalink · Reply

Hi.

Is this plugin still being supported and updated?

In version 2.3 of WordPress the plugin has a small issue. You can no longer grab and drag the mouse across to select the code when editing an instance of the rotator.

Try editing your code in the box, you’ll see what I mean.

This is my favourite plugin and is so versatile I’m hoping for an upgrade…

cheers!

said on October 1st, 2007 at 00:59 · Permalink · Reply

Hi. I’m a first time user and a total novice. I cannot save the new ads to my widget. I open the code pop up, delete my old code, add the new code and then close the window. That should be it right? When I do this the new ads don’t save. I’ve cleared my cache and cookies and still nothing. Please can you help?!

said on October 13th, 2007 at 09:55 · Permalink · Reply

Lisa… once you’ve closed the window you have to do a save updates….

said on November 7th, 2007 at 06:27 · Permalink · Reply

Great and easy to use widget – but, just a question, how do I add another instance of the Widget? I tried renaming and uploading another file but it isn’t showing in the list. Probably obvious ot seasoned WP users but it’s got me stumped!

said on November 7th, 2007 at 06:33 · Permalink · Reply

Oops figured it out! Forgot to activate the new AdRotator in the Plugins… duh (well I’m over 50 gimme a break)

said on November 7th, 2007 at 06:36 · Permalink · Reply

Oops agin, no it doesn’t work in 2.3 – plugin generated a fatal error… is this what will be fixed in the new release maybe? But still happy that it works so well!

Bert Degenaar
said on November 17th, 2007 at 11:05 · Permalink · Reply

This pluggin is working great. No difficulties getting it up and running. Great job. Thx alot.

Brian
said on November 20th, 2007 at 22:26 · Permalink · Reply

Hello, the adrotator is working fine but the ad address link would also show on a widget that is underneath it, for example if a have a text widget underneath the ad rotator the text would show underline and if you click on it will take you to the ad website that is showing on top.

Please let me know how can I fix this.

Thank you.

said on December 18th, 2007 at 22:04 · Permalink · Reply

Hello —

I have installed the adrotater plugin in the plugin directory along with the other plugins, but it doesn’t show up in my WordPress plugin admin panel like the other ones. Any thoughts? I’m using 2.3.1.

Thanks, David

said on December 18th, 2007 at 22:07 · Permalink · Reply

Never mind; I just had to log out and log back in; now it’s there. (I had previously also updated the widget.php module, as mentioned above in #15.)

— David

said on December 18th, 2007 at 22:26 · Permalink · Reply

Actually, now if I have the plugin activated, I lose access to my widgets admin screen until I turn the plugin off. Again, any thoughts would be appreciated.

— David

-- cobalt
said on December 28th, 2007 at 07:55 · Permalink · Reply

If I have my own directory of jpg images that I want to rotate through, what “text” / “code” could I use to randomly go through the ads?

stilfx
said on January 2nd, 2008 at 06:00 · Permalink · Reply

Is there any way to not use widgets with this and do inline ads?

said on January 3rd, 2008 at 18:19 · Permalink · Reply

I unwittingly put some javacode in my ad rotator box. Unfortunately, it crashed and i cannot simply go back in and change what is in the box. I even deleted and re-installed adrotator and it still doesn’t work. I just don’t understand and now my whole blog is damaged. any thoughts?

Ninjadoll
said on January 10th, 2008 at 08:53 · Permalink · Reply

Chris, you may wish to use your phpmyadmin and see whether the crashing code is still in your database. If it is, flush it. You should then be able to reinstall the widget without it repeating the process. Look for whatever entry has “Ad-Rotator” (or similar) and browse it to find the offending entry.

Ninjadoll
said on January 10th, 2008 at 09:01 · Permalink · Reply

I don’t want to use this plugin as a sidebar widget, I want to call it from elswhere on the site. Is there a way to make it work independently so I can stick it in a post?

said on February 7th, 2008 at 06:16 · Permalink · Reply

I have adsense in my blog. Now I want to install ad rotator for amazon. I am afraid there will be some problems. Is is OK ? Please advice.
Thank you.
Bambang Udoyono

said on February 17th, 2008 at 14:30 · Permalink · Reply

Has this plugin been updated lately – ie to work in later/latest WP versions?

john
said on March 4th, 2008 at 02:37 · Permalink · Reply

I am using wordpress 2.33 WITH K2
I am not a programmer.
I’ve enabled Ad Rotator 1.0.1

What is the code that I would use to get the plugin to appear in the K2 Sidebar Manager.

I would love it if this was a “module” for K2.

said on March 19th, 2008 at 16:21 · Permalink · Reply

У меня ничего не получается :( Хотя делаю по инструкции, но виджет в СайдБар Виджетс не появляется :( Менять тему? Обновлять ВП (у меня 2.1.3)?

said on May 29th, 2008 at 15:44 · Permalink · Reply

Awesome wordpress plugin, which can do alot of things :) , i really like it!!! however doest it work with wordpress 2.5.1 ? It wasn’t working when i was using ?

let me know please, whats going on..

said on June 28th, 2008 at 13:33 · Permalink · Reply

Thanks for sharing about what looks to be a good plugin. Getting it now to try it out on my blog. Much appreciated.

said on July 11th, 2008 at 15:46 · Permalink · Reply

Hi. I just installed this plugin on the newest version of WordPress. It seems that it is not rotating the images, but displaying both of them at the same time. You can see the widget at the bottom of the left sidebar on my blog, http://www.highcountrymomsquad.com

English& Proud
said on September 7th, 2008 at 04:53 · Permalink · Reply

Erm… The UNION FLAG should be used for English (top right corner of your website) NOT the American flag, they didn’t invent the language and STILL can’t speak it properly.

Please amend this as it is offensive to REAL English people.

More comments: 1 2

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