How To Display AdSense & Yahoo Publisher Ads Using AdRotator Plugin for WordPress

By Angsuman Chakraborty, Gaea News Network
Wednesday, August 30, 2006

AdRotator is a WordPress plugin which you can used to randomly rotate your ads (including but not limited to AdSense, Yahoo Publisher Network, Clicksor, Chitika etc.) on WordPress blogs. It allows you to display an advertisement (which is randomly selected from a group of advertisements specified in a text file) at your chosen location. The most frequent question I get is how you can use it to display AdSense ads, with an example.

AdRotator plugin can be used to easily rotate between AdSense, Yahoo Publisher Network ads and any other javascript based ad codes in combination and in a single file. There is however a small trick to it. You need to compress the ad code in a single line. Let me illustrate with an AdSense example.

Suppose your adsense ad is as follows:
<script type="text/javascript"><!–
google_ad_client = "pub-xxxx";
google_ad_width = 728;
google_ad_height = 15;
google_ad_format = "728×15_0ads_al_s";
google_ad_channel ="";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "9C0000";
google_color_url = "9C0000";
google_color_text = "000000";
//–></script>
<script type="text/javascript"
src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

Then you need to reformat it as below:
<script type="text/javascript">google_ad_client = "pub-xxxx";google_ad_width = 728;google_ad_height = 15;google_ad_format = "728×15_0ads_al_s";google_ad_channel ="";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "9C0000";google_color_url = "9C0000";google_color_text = "000000";</script><script type="text/javascript" src="https://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

Note: The above code is in a single line. Place as many as such ad codes in a single file and you can rotate between them.

This idea can be used with Yahoo ads and any other javascript based ad codes. If you face problems then you have most likely messed up your ad code somewhere.

Here is another example for other types of ads. You can refer to the AdRotator user manual for further details.

BTW: I am planning to release AdRotator Pro version in about a couple of weeks. It will make it much much simpler to manage your ad-strips, no tricks like above and no need to change your ad code, will allow placing multiple ads from the same file on the same page, without duplication, allow rotating between say Google & Yahoo ads without conflict and tons of advanced options for beginners and pro alike and lots more.

Discussion
September 2, 2008: 10:10 am

[...] AdRotator: Displays an advertisement (which is randomly selected from a group of advertisements specified in a text file) at your chosen location. Also see: How To Display AdSense & Yahoo Publisher Ads Using AdRotator Plugin for WordPress [...]

April 5, 2008: 3:08 pm

Hey, thanks for this awesome plugin.
I managed to get it work on my blog.
The thing is, it doesn’t properly show adsense. Hmm..doesn’t show at all. maybe because of lining up the code in 1 line breaks it.

Does this work with the new adsense code?

August 23, 2007: 2:11 pm

Yes, but you have to modify it. Or you can contact us for developing it for you.


Bill Vick
August 23, 2007: 11:42 am

Can this work in RSS feeds?


lol
April 21, 2007: 4:59 pm

>then you need to reformat it as below, >

well it is against google ad terms , what u think abt that ?

April 7, 2007: 10:56 am

i think this could work on my image hosting site photosharingworld.com


Simone
September 2, 2006: 10:19 pm

Hmmmm it wouldn’t include my php include I’ll try it without the brackets.
These are the two I tried but with php brackets.
php echo getad ’test1’;
php echo getad ’test1,test2’;


Simone
September 2, 2006: 10:14 pm

Hello Angsuman, I am trying to use your ad rotator
but I am getting this error.
Parse error: unexpected T_STRING, expecting ‘,’ or ‘;’ in

I even tried it like this: with no luck.

Do you know what it is asking me to adjust?
Thanks, Simone

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :