Thesis Tutorial – Rotating Banner Ads without using a Plugin

BlakeConsultants - The Leading Experts in Biometric Access Control and Time & Attendance

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 Tutorial – Rotating Banner Ads without using 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

The download was made available on 25 November 2009 and is in zip format. The file size is 834 bytes and has currently been downloaded 399 times.

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.

  • Twitter
  • Digg
  • Delicious
  • Submit post to StumbleUpon
  • Submit post to Facebook
  • Submit post to LinkedIn
From the desk of George Serradinho

I am the proud owner of Serradinho Blog and have made this my second home. I'm into blogging, downloads, WordPress, meeting and helping others, etc. Basically the internet in general :) Serradinho Web Services is my own company whereby I offer my services to clients. This ranges from web design, website upgrades, theme customizations, support, premium WordPress plugins and many more .....

View all posts by , there might be other posts that interest you.

{ 32 comments }

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

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.

George Serradinho September 8, 2009 at 9:02 pm

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

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

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” =-.

George Serradinho September 8, 2009 at 9:33 pm

@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 :)

Compute Live September 8, 2009 at 8:35 pm

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

George Serradinho September 8, 2009 at 9:02 pm

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

Surender Sharma September 8, 2009 at 8:38 pm

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

George Serradinho September 8, 2009 at 9:03 pm

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

clarky September 9, 2009 at 9:12 am

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? =-.

George Serradinho September 9, 2009 at 11:36 am

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

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

George Serradinho September 11, 2009 at 6:56 am

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

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

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

George Serradinho September 11, 2009 at 11:29 am

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

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

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

Hi
Where do I place the code listed above?

Thanks
Tom

George Serradinho September 22, 2009 at 7:26 am

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

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

George Serradinho September 22, 2009 at 11:43 am

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

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

Tinh September 28, 2009 at 4:44 pm

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ỉ =-.

George Serradinho September 29, 2009 at 7:31 am

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

Tinh October 1, 2009 at 11:56 am

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

Tinh October 2, 2009 at 10:25 am

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ử =-.

George Serradinho October 2, 2009 at 1:24 pm

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

Tinh October 2, 2009 at 4:57 pm

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

tutorial blog October 3, 2009 at 7:01 pm

thank for share.
really useful
.-= tutorial blog´s last blog ..Blogger Tube Themes =-.

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

George Serradinho October 13, 2009 at 7:16 am

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

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

George Serradinho October 15, 2009 at 7:14 am

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

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? =-.

Comments on this entry are closed.

{ 2 trackbacks }

Previous post:

Next post:



    

Join our Revenue Sharing Program today.

Follow George Serradinho on Twitter - username: @gfserradinho.   Connect via Facebook.   Connect via LinkedIn.   Follow George Serradinho on Google.   Connect via YouTube.   Connect via Skype.

*/ ?>