WordPress Widgets: Ad Rotator

Posted by Dmytro Shteflyuk on under WordPress · English (136,613 views)

Компания Automattic выпустила отличный плагин для WordPress — WordPress Widgets, который может быть использован для настройки Вашего блога без знания HTML. Вам вообще не нужно редактировать Вашу тему WordPress! Просто выберите необходимый виджет и перетяните его на боковую панель. Уже существует множество виджетов, созданных разными разработчиками, которые Вы можете использовать в своем блоге.

У меня не получилось найти виджет, который бы брал несколько кусков HTML-кода и отображал один из них на боковой панели, потому я решил написать свой. Вы можете скачать плагин Ad Rotator, распаковать архив, скопировать adrotator.php в каталог BLOG_DIR/wp-content/plugins/widgets/ и активировать его на странице Плагины.

Вы можете увидеть пример на этом блоге: несколько моих любимых книг с сайта Amazon выводятся в боковой панели, для каждого запроса отображается одна книга.

Окно редактирования выглядит следующим образом:

Окно редактирования Ad Rotator

Вы можете ввести заголовок Вашего виджета и HTML-код. Куски кода разделяются с помощью конструкции <--more-->.


Вы всегда можете загрузить последнюю версию плагина здесь.

49 Responses to this entry

Subscribe to comments with RSS

JR @
said on Май 21, 2007 at 17:50 · Permalink

Hi, I added a simple bit of coding to make the super ad rotator take php (and java if it didn’t take that already it does now)

In the function widget_adrotator just before the place this code (note I am showing the existing ‘div’ bit below to make clear where to place the extra line)

<?php $chunks[$chunkno] = eval_html($chunks[$chunkno]);?>
<div class="adrotatorwidget"><?php echo $chunks[$chunkno] ?></div>

Now, at the very end of the php file copy paste this coding:

function eval_buffer($string) {
    $ret = ob_get_contents();
    return $ret;

function eval_html($string) {
    return preg_replace_callback("/(<\?php|<\?)(.*?)\?>/si",

And now it takes php as well..

If you like a similar function but just for anywhere in the body, I just finished programming a piece of code… it is slightly limited in that you can only use it in one location for now..

Leave a message here if you like to test it.

said on Май 21, 2007 at 18:14 · Permalink

Hello, thanks for suggestion.

If you don’t mind, I could integrate your code with the plugin and add some options (to render or not the div, to execute or not PHP code).

Of course, I would add “thanks” to the changelog along with the link to your site.

said on Июнь 6, 2007 at 16:45 · Permalink


I have set up two adrotator widgets, one with linksynergy ads and one with amazon ads, however they are both displaying the linksynergy ads.


If you view source you can see it references adrotator-1 and adrotator-2.

If I swap the code around I just get the amazon ads.

At one point it was even displaying google ads (i am using adsense manager).

Please help.

stash @
said on Июнь 17, 2007 at 15:17 · Permalink

I have a similar problem to the above user. I have used this widget on several blogs in the past and they all worked great, but now i have one new blog that i just built and it got set up with wordpress 2.2 and if i put in more than on instance of the rotator they will all show the same rotator.

is there something in w-p 2.2 that i can change to fix this?

for now im just going with one instance of this program running at a time

thanks if there are any options to fix this error

I LOVE THIS WIDGET and would love it on all my future blogs


said on Июнь 19, 2007 at 04:41 · Permalink

First of all, great plugin. I’m finding it very useful. However, I am running into the same problem that Steven seems to be having. I can only run one ad rotator at a time, because the second rotator simply reflects the same ads as the 1st rotator even with different chunks of html in them.

What would you suggest I look at?

JR @
said on Июль 2, 2007 at 16:48 · Permalink

Hi all,
since I can’t remember what exactly I changed, but you can download the working version from my site.


Dmytro Shteflyuk I dont know m8 if you got my email a while ago with the updated code, but please post a later version here when ever it is ready. I dont like putting a link up on my site, but feel sorry for those having issues using your great plugin!

said on Июль 4, 2007 at 07:26 · Permalink

Great plugin. Works well. Is there a way to run it in multiple rotator?

JR @
said on Июль 13, 2007 at 19:18 · Permalink

Goe D
on the WP screen where you manage your widgets you can specify how many adrotators you like to use. Set that number and apply and new ad rotator widgets will show..

Download the adjusted version on my site as mentioned above for this to work on the latest WP versions

said on Июль 15, 2007 at 03:34 · Permalink

Hey Jr ! I’ve been trying to get your version off your site, but I keep getting this same error when trying to download the file:
Fatal error: Call to undefined function: add_action() in /home/jrbeltma/public_html/downloads/ad_rotator_plugin.php on line 23
Is it just me or is the server down ?

JR @
said on Август 25, 2007 at 14:28 · Permalink

Hi there Alex,
I didn’t check if the latest version has been posted here, so if you do try taking the plugin from my site remember 2 things:

1. Right click and save target (or link) as….
and dont left click as it will try and execute the script :)
2. – http://www.jrbeltman.com/downloads/ad_rotator_plugin.php
is a plugin that can be placed anywhere on your site, but isn’t the widget as Dmytro programmed. It is very similar in what it does though. But again isn’t a widget for your sidebar
- http://www.jrbeltman.com/downloads/adrotator.php is the working version of Dmytro’s sidebar widget!

Ramil @
said on Сентябрь 9, 2007 at 10:26 · Permalink

Does it support rotation of Javascript?

said on Сентябрь 14, 2007 at 04:06 · Permalink


Juist like to say I LOVE this versatile widget. THANK YOU!

I use it on my site to rotate album covers, giving a fresh look to the graphics on every visit. Superb!

Just one question…

Why the maximum of 9 rotators? Any way I can change something to make it higher (30?)? Or is there a WordPress limitation?

said on Октябрь 8, 2007 at 05:53 · Permalink

I have a modified version of adrotator allowing you to use ads with multi-line codes without having to convert them to single-line codes. Read about it here

said on Апрель 6, 2009 at 07:10 · Permalink

how to delete this plugins. please help me. now i can’t use this plugins. i will add after some time.

i added this plugins. but its not showing in plugins list. how can i deactivate or unistal.

Please, help

Dear Nepal

More comments: 1 2

Comments are closed

Comments for this entry are closed for a while. If you have anything to say – use a contact form. Thank you for your patience.