How to Add Rotating Banner Ads in Sidebar of Thesis Theme

This video tutorial section I am going to explain about how to place rotating banner ads in thesis theme. What is rotating banner ads? Normally rotating banner ad means ad location has been changed for every impression. For example I am having six ad spots in my sidebar. I want to place six different 125×125 banner ads in my sidebar and also I need to rotate these ads for every impression ie, for every reload of the single page the banner ad moved to another ad spot in the available six ad spots. This tutorial tells about how to place these rotating ads.

Here I am going to tell you how to place inside multimedia box and sidebar. Just copy and paste the following code in custom_function.php or launch.php. any one of the above mentioned file you can paste the code.

/*rotating banner ads*/
function banner_ad_rotator() {
echo ' <div><center>';
/*Rotating Ad  number 1*/
$ads = array(array("title"=>"AWeber - Email Marketing Made Easy",

/*Rotating Ad  number 2*/
array("title"=>"Click here to watch The Conversion Blogging Video",
"img"  =>"",
"url"  =>"",),

/*Rotating Ad  number 3*/
"img"  =>"",
"url"  =>"",),
/*Rotating Ad  number 4*/
"img"  =>"",
"url"  =>"",),
$ads = array($ads[0],$ads[1],$ads[2],$ads[3]);
foreach($ads as $ad){
<a href="<?=$ad["url"]?>"><img src="<?=$ad["img"]?>" alt="<?=$ad["title"]?>" border="0" width="125" height="125"/></a>
echo ' </div></center>';
add_action('thesis_hook_multimedia_box', 'banner_ad_rotator');

To paste the code in custom_functio.php. login your wordpress admin.

  1. Choose ‘custom file editor’ under thesis options in left sidebar of the wordpress dashboard.
  2. Select custom_function.php file and click on edit selected file.
  3. Paste the above code and save it the visit your site.

To place the code in launch.php login your ftp.

  1. Select the path public_html/
  2. Open the file by right clicking on the file.
  3. Paste the above code and save it the visit your site.

You should use any one way only. Ad will appear as follows.

Rotating ads

Rotaing banner ad

In the second  impression or after the reload of the page Ad appear as follows.

ad after reload.

Rotaing banner ad after reload

The above code I am using only four ad spots inside multimedia box. This code you should replace your banner ad “url”,  “img” ,and title. If you want to place one more ad.

Copy and paste the below after ad number 4.


"img"  =>"",

"url"  =>"",),

You should change your own title, url and image in the above code and also add $ads[4].

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

How to Place Rotating Ad in Sidebar

Thesis theme offers number of hook functions to place your ads in every location of your theme like above header, sidebars, inside multimedia box, below multimedia box and other locations. Only thing is you need to select corresponding hook for the placement of ad. You can place any location in the theme.

To place the ad in sidebar by changing the hook function, example.

add_action('thesis_hook_before_sidebars’, 'banner_ad_rotator');

If you want you style your ad spots by using custom.css file

This is for optional. You can change adblock size using the following code.

.custom .adblock {

Width: 270px;


Height:  260px;


Share your experience in comment section.

For more checkout our all Thesis theme tutorials..

{ 9 comments… add one }

Leave a Comment

  • Gabe | December 28, 2009, 7:27 PM

    Very cool. Changing the ads up can help mitigate some ad blindness. Now if there’s a way to track performance based on these ad blocks, that would be incredible.

    • Pascal December 29, 2009, 4:18 AM

      Yes. Gabe. Can we do that track analysis by ourself? Is there any tools, can you recommend?

  • Ahmad Wali February 14, 2010, 3:40 AM


    This is not working because when I replaced the code of layout.php the blog was saying parsing error in layout.php can you guide where exactly to put the code and after which line? I couldn’t get it as I am newbie for thesis.. Thanks.

    • Pascal February 14, 2010, 9:38 AM

      Give me Your site link then only we rectify your problem.

  • monty July 19, 2010, 3:21 AM

    this code did not work

  • chris October 21, 2010, 1:57 AM

    didn’t seem to work for me either

  • Rakesh Kumar January 9, 2011, 1:26 AM

    Very easy to understand tips but some links we need to change! No problem we will do that! Thanks Pascal

  • Mark November 27, 2011, 6:35 AM

    What if you wanted to display multiple (4 – 6) ads, but rotate them individually as opposed to displaying all at once? Can these be linked to open a blank browser window? Can this be done in a “second” multimedia box like in your other tutorial as opposed to the Thesis default multimedia box? Thanks.

  • waqas December 7, 2011, 8:08 PM

    plz help me

    in Teasers = Teaser Display Options =
    Warning: Invalid argument supplied for foreach() in /home/u841794885/public_html/wp-content/themes/thesis_182/lib/classes/options_design.php on line 1258

    plz send me the corret file plz resolve my this problem