Thesis Tutorial: Ads in Sidebar

by Franklin Bishop on April 26, 2009

thesis-designerAfter posting my tutorials on how to add a banner ad in your header, someone asked me how to add 125×125 ads in your sidebar. This can be easily done by using my custom CSS and custom function below.

Custom CSS

.custom .ads {
	text-align: center;
}
.custom .ads img {
	margin: 1px;
}

Above is the custom CSS for the ads. It makes sure that each one is centered. The one pixel margin is the spacing between each ad. The higher the pixel value the more spacing there will be between each ad. You can change it according to your own preferences.

Custom Functions

function custom_ADS() { ?>
<div class="ads">
   <h3>Franklin's Sponsors</h3>
   <a href="#"><img src="http://franklinbishop.net/wp-content/uploads/2009/04/add.gif" alt="" /></a>
   <a href="#"><img src="http://franklinbishop.net/wp-content/uploads/2009/04/add.gif" alt="" /></a>
   <a href="#"><img src="http://franklinbishop.net/wp-content/uploads/2009/04/add.gif" alt="" /></a>
   <a href="#"><img src="http://franklinbishop.net/wp-content/uploads/2009/04/add.gif" alt="" /></a>
   <a href="#"><img src="http://franklinbishop.net/wp-content/uploads/2009/04/add.gif" alt="" /></a>
   <a href="#"><img src="http://franklinbishop.net/wp-content/uploads/2009/04/add.gif" alt="" /></a>
  </div>
<?php }
add_action('thesis_hook_before_sidebars', 'custom_ADS');

Above is what you’ll need to put in your custom functions file. You’ll just need to change the URLs and the image URLs. Then you will be set. If you would like to place it above sidebar 1 then put thesis_hook_before_sidebar_1 and if you want to put it before sidebar 2 then put thesis_hook_before_sidebar_2.

If you would rather put it somewhere else in your sidebar then you can just take the HTML out of the custom function above and place it in a text/HTML widget. It will work just like if you were to add a function above the sidebar. There should be no problems with this.

Below I have taken a screenshot of what it would look like on my blog. I just used grey images for example ads. If it doesn’t come out the same way, then just ask for some help. You can either ask me on here or find me on the thesis forums.

screenshot-ads

{ 8 comments }

Nokia Mobile Talk April 27, 2009 at 8:44 am

Excellent tutorial Franklin thanks for taking the time to explain :)

Mark May 5, 2009 at 9:02 pm

Franklin,

I tried your coding on my test site (above) and can’t seem to get it to work. I am using Thesis OpenHook.

Any suggestions?

iklan May 8, 2009 at 11:33 am

great tutorial, thanks your tips for me.

Poster Printing May 22, 2009 at 12:18 am

Some really useful information you’ve posted here, thanks so much! This will be really helpful in making sure the coding of our ads is correct. You write really well too! Thanks!

cars May 26, 2009 at 2:09 pm

thank you so much , it’s been a long time since i was looking for how to place 125*125 ad places on my website , i though it was more difficult than that :) thank you

Stacie @ newmommyhelp.net July 10, 2009 at 11:15 pm

Thank you! I’ve tried other tutorials, but I could never get my ads to show up right. Now, it looks great.

Renn July 13, 2009 at 3:17 am

Nice tutorial. However, could you explain how to make these links clickable?

Neill Watson July 24, 2009 at 10:44 am

Renn, simply replace the hashtag in the ‘a href’ bit with a full url and the ‘img source’ bit with the full url to where your advert graphics are.

Nice simple tutorial, many thanks.

Comments on this entry are closed.

{ 7 trackbacks }

Previous post:

Next post: