Please enter a search term to begin your search.

AdRotator Plugin


AdRotator is a WordPress plugin which displays an advertisement (which is randomly selected from a group of advertisements specified in a text file) at your chosen location. It has been tested and works in all version of WordPress (future and past proofed). It can also be used with other CMS systems or anywhere where PHP is supported. It does one job and does it well. Enough said. If you find this useful, let me know. Links are appreciated too.

Note: Contact us for custom modification requests.


AdRotator was created with few simple requirements. 
  1. It should allow rotating (randomly) between any number of advertisements (or other code or images etc.)
  2. It should be efficient.
  3. It should be simple to use.
  4. It should be simple to install.
  5. It should be simple to uninstall.


This can be used to distribute your Ads impressions between various providers and to provide variety to users. It can also be used to randomly include any other code or even to randomly display images, text messages etc. The usage is limited by your imagination only. You can also use it to display rotating advertisement within your posts or pages.The code can be used with non-WordPress systems too.


You can refer to comments for further clarifications and an example of the text file.


No configuration is required for the plugin itself. However you need to upload a file (or files) with your ad code in wp-content directory. And you need to insert code in your template files (of your theme) at location of your choice (referencing the file to fetch ads from) to display ads. Details are provided in the User Manual.


Download AdRotator - AdServing Solution for WordPress Blogs

Please read the User Manual thoroughly after you download the plugin.

User Manual

There are three simple steps to use AdRotator.

First you should upload the plugin to your wp-content/plugins directory and Activate the plugin from Plugin Manager.

Then you should create one or more files (depending on the number of Ad groups) in wp-content folder with names ending with .txt. For example: banner.txt or skyscrapper.txt etc. Each file contains a specific type of Ads, normally with the same size (though not required to be so). If you name the file indicating the type of Ad it displays, then it will be easier for you to remember later.

You can either create them on your desktop and upload them using ftp or create them directly on the server or use the Admin interface, your choice.

Each of these files contains one or more lines. Each line contains the Ad code for any particular advertisement.

What if your ad code is multi-line?
Normally Ad codes are provided in single line. However in certain cases like for example, multi-line Ad codes are provided. In that case either convert the Ad code to single line manually or just take the most relevant portion of the code at the end and insert it in the file. The remaining code (which normally will be used to setup some parameters) will remain above the location (in your template file) where you would insert the function to select an ad from this ad group. So when this particular ad is chosen, then all the required code will be available and the ad will be visible. Read the AdSense discussion below for further clarification.

This can be used to display Google AdSense, LinkShare or your custom Advertisements.

For AdSense keep the top portion of the code where settings are provided, as-is in your template. Compress the last three lines that includes a file, which actually inserts the Ad, in a single line and insert it in your text file.

To use multiple AdSense ads you need to concatenate the settings portion of the code in a single line along with the last section which includes the file which displays the ad, all in a single line. While this requires that you remove newlines from AdSense code, it has been verified to be in compliance with AdSense policies.

In case you are wondering it doesn’t violate any terms of service regarding competing ads because the final HTML (at that location)displays Ads from only one source which was selected

Finally you need to specify a location to display your ads. Add the code after providing the actual ad file name without the .txt extension) anywhere in your template.

The AdRotator looks for a text file as specified in the Ad file name and with a .txt extension. So if you have a code like:
<?php echo getad('bannerad'); ?>
then AdRotator looks for wp-content/bannerad.txt file. If it finds it, it picks up a line randomly from the file and inserts it in your template/html.

You can alter the weight of an Ad (how often you want it displayed) by repeating the same ad line multiple times.

Note: If it cannot find the specified file or cannot find any ad in the file then it does not insert anything.


  1. Upload or move the Plugin file (adrotator.php) to your wp-content/Plugins directory.
  2. Log in to WordPress.
  3. Click Plugins from the main menu.
  4. Scroll to find the name of the Plugin - Ad Rotator, and click Activate.


   1. Log in to WordPress.
   2. Click Plugins from the main menu.
   3. Scroll to find the name of the Plugin - Ad Rotator, and click Deactivate.

This disables the Plugin. You can also delete the adrotator.php file from wp-content/plugins directory and referer.txt (if created) from the wp-content directory for permanent removal.

Your comments and suggestions are welcome.