HostGator - The BEST Web Hosting comapny on the net. Great packages at LOW prices.

Thesis Tutorial – Rotating Banner Ads without using a Plugin

by George Serradinho on September 8, 2009



I have seen a few blogs have rotating banners using plugins. I recently reviewed AdRotate Plugin to show you how to do it via a plugin, but now I will show you how to do it without using a plugin on Thesis. It’s not as hard as it sounds, very easy in fact.

For this example I am displaying 6 rotating banners ads. You could change it to display less or more ads, the choice is yours. You will have to change the code below depending on the number of ads you want to show.

$ads = array($ads[0],$ads[1],$ads[2],$ads[3],$ads[4],$ads[5]);

The array for the ads starts on 0, so it will always be one number less than you want to see. Example: If you wanted 4 ads, then you will start from 0 and go up until 3.

Below is an example of what it will look like, you could use this anywhere in your site and custom the layout as you feel. The longer the width, the more banners you will fit in.

Thesis - Rotating ads without a plugin

Thesis - Rotating ads without a plugin

The PHP function which is displaying the banner ads at the bottom of the sidebar. You can change that location if need be. I have actually placed this in my footer which will display the ads on posts/pages, but this example is for the sidebar.

This php function will open all banner ads in a new window. If you don’t want that, then remove target=”_blank”.

You can change the space between banners, add borders, etc. If you want you could put the banners within another div and style that div. The margin is set to 6 right now, change that and the space between the banners will increase/decrease.

Download: Thesis Tutorial - Rotate Banner Ads (75) 834 bytes

I have edited this post and put the CSS and PHP in a text file. Download the zipped file and get it working on your site in less than 10 minutes.

Final Thought

I hope you enjoyed this Thesis tutorial and maybe have some kind of feedback for me. I’m dying to hear what you thought of it.

I have written a few other Thesis tips and tricks which will be published later this month, be sure to come back and have a look.

Submit post to StumbleUpon Submit post to Twitter Submit post to Delicious Submit post to Digg Submit post to Reddit Submit post to Technorati Submit post to Facebook Submit to Shoutmeme.com

Other Interesting Posts:

WordPress & Thesis Customizations

This webiste is using Thesis theme & WordPress. I can create you a similar website or update yours.

View my services or portfolio for more details.

Author Information

Article by George Serradinho

I am the proud owner of Serradinho and have made this my second home. I'm into blogging, downloads, WordPress and the internet in general. I also love meeting and helping others and learning new techniques.

{ 2 trackbacks }

60 Wonderful And Helpful Thesis Customization Tutorials - Cash-Bandit.com
September 13, 2009 at 4:04 pm
Tạo Rotating Banner Trên Thesis Mà Không Cần Plugin | Blog Kiếm Tiền
October 3, 2009 at 4:01 pm

{ 32 comments }

1 Klaus @ TechPatio September 8, 2009 at 8:35 pm

Follow on Twitter Follow @TechPatio on Twitter.



I know this post is about on how to do rotating ads without a plugin :) But I’d just like to recommend the one I’m currently using, it’s a plugin of course: “Datafeedr Random Ads V2″.

It’s very easy to use and integrates with Thesis sidebar using Widgets or you can include 1 line of PHP code into your custom_functions.php (plus the hooks-thing of course) and then you just edit/paste HTML ad codes into “Datafeedr Random Ads V2″ plugin whenever you want to add something to the rotation.

2 George Serradinho September 8, 2009 at 9:02 pm

Follow on Twitter Follow @gfserradinho on Twitter.



@Klaus – I understand, but the more plugins you use the more load it’s on your server. this is to show you how to do it with using a plugin.

3 Klaus @ TechPatio September 8, 2009 at 9:06 pm

Follow on Twitter Follow @TechPatio on Twitter.



Yes – but you’d still need a plugin to track clicks (and maybe even impressions) – otherwise you’re pretty much shooting in the blind with your ads, unless:

1) Your advertisers offers you click-tracking service and you don’t mind logging in to several sites to check.

2) You just receive a monthly pay to have the banner up and impressions/clicks doesn’t matter.
Klaus @ TechPatio´s last blog ..Google’s UFO Logo Explained – “All Your O Are Belong To Us” My ComLuv Profile

4 George Serradinho September 8, 2009 at 9:33 pm

Follow on Twitter Follow @gfserradinho on Twitter.



@Klaus – I use goCodes to see the click stats on banners. That is a plugin and it could be used for other purposes as well, but you are right about the number of impressions. Thanks for mentioning that :)

5 Compute Live September 8, 2009 at 8:35 pm

Follow on Twitter Follow @computelive on Twitter.



For now I don’t have any banner ads, on my site for now. But I think i`ll be adding some soon…
Compute Live´s last blog ..Windows 7 Video Ads My ComLuv Profile

6 George Serradinho September 8, 2009 at 9:02 pm

Follow on Twitter Follow @gfserradinho on Twitter.



@Compute Live – if you have a lot of plugins installed, then I suggest using this method.

7 Surender Sharma September 8, 2009 at 8:38 pm

Follow on Twitter Follow @Technogati on Twitter.



Instead of using plugin to show random ads on blog,this is the best way.More plugins means more time for page load on server.Your way is the best for publishing random ads.Thanks for the creation…
Surender Sharma´s last blog ..How to Disable Copying of Content and Images of Your Blog My ComLuv Profile

8 George Serradinho September 8, 2009 at 9:03 pm

Follow on Twitter Follow @gfserradinho on Twitter.



@Surender – thanks man. It works well and you could use it all over your site.

9 clarky September 9, 2009 at 9:12 am

Follow on Twitter Follow @ggclarky on Twitter.



Oh, that is great, thanks. But I think that if AdRotate is so easy to use just like you said, why not just use it? Most people hate codes, me too. So I think that it is better to use plugin to do this :) .
clarky´s last blog ..How To Make Money From Blogging? My ComLuv Profile

10 George Serradinho September 9, 2009 at 11:36 am

Follow on Twitter Follow @gfserradinho on Twitter.



@clarky – if you are not comfortable in using code, then a plugin is best for you. If you are like me and can do both then you will weigh what you can do and use.

11 ankit September 11, 2009 at 5:34 am

I am waiting for your tutsfor drop down nav bar..i read that in few blogs but its not clear .I hope you will post soon about it.. :)
ankit´s last blog ..Go natural way for breast enhancement My ComLuv Profile

12 George Serradinho September 11, 2009 at 6:56 am

Follow on Twitter Follow @gfserradinho on Twitter.



@ankit – I will try and get a post out for you about drop down menu’s

13 Roseli A. Bakar September 11, 2009 at 11:26 am

Follow on Twitter Follow @EzyBlogger on Twitter.



Hey George,

This is a great tip for thesis users for have been using a lot plugins and this will help a bit with their site loading time. Cool.
Roseli A. Bakar´s last blog ..Blogging Demystified My ComLuv Profile

14 George Serradinho September 11, 2009 at 11:29 am

Follow on Twitter Follow @gfserradinho on Twitter.



@Roseli – I thought I would share it with others as I know many users have loads of plugins installed.

15 ankit September 12, 2009 at 8:29 pm

that post cud be a rocking post..i hardly find any info about that drop down thing.
ankit´s last blog ..Team India reaches no 1 spot in ICC Cricket ranking My ComLuv Profile

16 Tom Mc Carrick September 21, 2009 at 11:42 pm

Hi
Where do I place the code listed above?

Thanks
Tom

17 George Serradinho September 22, 2009 at 7:26 am

Follow on Twitter Follow @gfserradinho on Twitter.



@Tom – if you are using Open hook then you could use thesis_hook_before_sidebars or thesis_hook_after_sidebars. Otherwise you can just copy it as is into yuor custom_functions.php file.

18 Tom Mc Carrick September 22, 2009 at 11:13 am

Thanks George – I inserted in the after_sidebars Openhook section, but now I get an error message where the buttons should be:

Parse error: syntax error, unexpected ‘}’ in /home/tmccar/public_html/wp-content/plugins/thesis-openhook/functions.php(841) : eval()’d code on line 42
Tom Mc Carrick´s last blog ..Business Card Printing Serves The Purpose of Promotion My ComLuv Profile

19 George Serradinho September 22, 2009 at 11:43 am

Follow on Twitter Follow @gfserradinho on Twitter.



@Tom – please use my code and insert it into the custom_functions.php file then. It should work just like that. As for Open Hook, not exactly sure how you would implement it.

20 Tom Mc Carrick September 22, 2009 at 12:08 pm

Thanks George, works great now!

Tom
Tom Mc Carrick´s last blog ..Business Card Printing Serves The Purpose of Promotion My ComLuv Profile

21 Tinh September 28, 2009 at 4:44 pm

Follow on Twitter Follow @eblogtip on Twitter.



I use WP125 plugin and it is easy. You can also track click and set dates for curtain period. Anyway thanks
Tinh´s last blog ..CheerLeaders: Động Lực cho các cầu thủ giữa giờ nghỉ My ComLuv Profile

22 George Serradinho September 29, 2009 at 7:31 am

Follow on Twitter Follow @gfserradinho on Twitter.



@Tinh – WP125 is cool, I use to use it, then I moved over to AdRotate. This helps users who don’t want to use any plugin.

23 Tinh October 1, 2009 at 11:56 am

Follow on Twitter Follow @eblogtip on Twitter.



But, how do i order this banner ads widget on the sidebar, e.g. i want to put the widget before recent comments but after recent posts. Thanks
Tinh´s last blog ..Các Ngân Hàng Việt Nam Cho Phép Verified PayPal My ComLuv Profile

24 Tinh October 2, 2009 at 10:25 am

Follow on Twitter Follow @eblogtip on Twitter.



Another thing that I tried but failed is how to increase number of ads from 6 to 8 or ten? Please share this either here or via email. I wanna be translating this and reposted but still need your permission. Thanks
Tinh´s last blog ..Google Wave chính thức mời người dùng thử My ComLuv Profile

25 George Serradinho October 2, 2009 at 1:24 pm

Follow on Twitter Follow @gfserradinho on Twitter.



@Tinh – I have just sent you an email showing 10 ads, you can remove if you want 8 instead.

26 Tinh October 2, 2009 at 4:57 pm

Follow on Twitter Follow @eblogtip on Twitter.



I got that, many thanks
Tinh´s last blog ..Google Wave chính thức mời người dùng thử My ComLuv Profile

27 tutorial blog October 3, 2009 at 7:01 pm

thank for share.
really useful
tutorial blog´s last blog ..Blogger Tube Themes My ComLuv Profile

28 Asif October 12, 2009 at 8:04 pm

Hi,

I pasted the above code into the custom_functions.php file and now I get the following error message when i try to access wordpress..

Could you possibly help me with this as i’m an amateur at this coding stuff.

>>ERROR MESSAGE >>

Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’ in /home/asifpat1/public_html/theultimateiphoneweblog.com/wp-content/themes/thesis_151/custom/custom_functions.php on line 58

29 George Serradinho October 13, 2009 at 7:16 am

Follow on Twitter Follow @gfserradinho on Twitter.



@Asif – have a look at the code you pasted. It might have changed some details.

30 Asif October 13, 2009 at 3:18 pm

Yeh, seems like it did. I had to redo the custom_functions file from scratch which is a annoying.

Any ideas why it changes something in the file when you paste a code into it?
Asif´s last blog ..Google Wave on your iPhone My ComLuv Profile

31 George Serradinho October 15, 2009 at 7:14 am

Follow on Twitter Follow @gfserradinho on Twitter.



@Asif – when I copy and paste it, it works fine with me. Not sure if you copy it and paste it somewhere before copying it to your functions file.

32 Anthony Bradley December 9, 2009 at 7:46 pm

I use the Pretty Link plugin for tracking clicks and you can use it to easily create a tracking URL for use with this ad rotation function.
Anthony Bradley´s last blog ..Are you drifting apart from your spouse? My ComLuv Profile

Comments on this entry are closed.

Previous post:

Next post: