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
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.
Other Interesting Posts:
- SimplePress WordPress Custom Thesis Skin
- Thesis Tutorial – Display Posts from Specific Categories on Homepage
- WordPress & Thesis theme Enhance Serradinho Blog
- Adding Google Buzz to your Posts & Pages using Google Buzz WordPress Plugin
- Thesis Customizations & 60+ Video Tutorials
WordPress & Thesis Customizations
This webiste is using Thesis theme & WordPress. I can create you a similar website or update yours.















{ 2 trackbacks }
{ 32 comments }
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.
@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.
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”
@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
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
@Compute Live – if you have a lot of plugins installed, then I suggest using this method.
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
@Surender – thanks man. It works well and you could use it all over your site.
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?
@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.
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
@ankit – I will try and get a post out for you about drop down menu’s
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
@Roseli – I thought I would share it with others as I know many users have loads of plugins installed.
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
Hi
Where do I place the code listed above?
Thanks
Tom
@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.
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
@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.
Thanks George, works great now!
Tom
Tom Mc Carrick´s last blog ..Business Card Printing Serves The Purpose of Promotion
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ỉ
@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.
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
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ử
@Tinh – I have just sent you an email showing 10 ads, you can remove if you want 8 instead.
I got that, many thanks
Tinh´s last blog ..Google Wave chính thức mời người dùng thử
thank for share.
really useful
tutorial blog´s last blog ..Blogger Tube Themes
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
@Asif – have a look at the code you pasted. It might have changed some details.
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
@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.
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.