Thesis Tutorial: Banner Ad in Header

by Franklin Bishop on April 19, 2009

thesis-designerPeople that are using the Thesis WordPress theme have been wanting to know how I added a banner ad in my header. Since others were having problems, including myself, with the traditional way of coding this, I decided to do it differently.

Below I have shown you what I put in my custom CSS file and custom functions file. I left my code in their so that it is easy to see where to delete and insert your own code.

Custom Function

function my_header_ad() { ?>
<div id="leaderboard_ad"><a href=""><img src="image url" alt="" /></a></div>
<?php }
add_action('thesis_hook_header', 'my_header_ad');

Custom CSS

.custom #leaderboard_ad { float: right; position: absolute; width: 468px; height: 60px; top: 15px; left: 502px; }

Now make sure you change the CSS so that it fits in your header. For top, the higher the pixel value the lower it will be. For left, the higher the pixel value the farther to the right it will be. You will have to play with it so it fits your header the way you like it.

Hopefully this Thesis Tutorial can help you get a banner ad in your header. As always, there are little things that can mess this up. So if you have troubles let me know.

{ 41 comments }

Lainie Petersen April 19, 2009 at 7:50 pm

Franklin,

I love Thesis too. . .have you ever tried working with ? I adore it.

Lainie Petersen April 19, 2009 at 7:51 pm

Argh! The link didn’t work…I was referring to the Open Hook plug-in for Thesis.

Franklin Bishop April 19, 2009 at 8:50 pm

Yeah, I didn’t like it much. I’m too use to helping people in the support forum who do not use it. I’ll add how to easily add it to the open hook plugin at the bottom.

Melody April 19, 2009 at 10:55 pm

The banner blends in really well with this theme..

John @ Wollongong Web Design April 19, 2009 at 11:52 pm

Yes your banner looks great and this tutorial is a big help to those who a want a similar one.

blinkky April 20, 2009 at 12:29 am

I agree with you melody. The header seems very comfort with the colors…

Ann @ Work From Home April 21, 2009 at 3:43 pm

Thanks for the great guide, I am not using Thesis, but I did find this helpful for my theme, as I have been trying to do this but neglected to change my CSS

uprinting.com promotions April 21, 2009 at 6:46 pm

Really true…I’m liking the colors!

Michelle April 21, 2009 at 10:35 pm

Hi, this didn’t work for me. I am actually trying to put two ads beside eachother (using the header hook) – not sure why my 2nd ad is not showing up.

Here’s what I have in the header hook:

And then in custom.css:
.custom #header_welcome { float: right; position: absolute; width: 168px; height: 90px; /*top: 15px; left: 502px;*/ }

The 2nd (welcome) ad doesn’t show up. Any ideas what I am doing wrong? Thanks!

Michelle April 21, 2009 at 10:36 pm

Hmm looks like my code didn’t display my previous comment. Here it is again (this is in my header hook):

Jorge Ledesma April 23, 2009 at 6:40 pm

Hey great tip, thanks for sharing, do you know any more tricks for perhaps a footer and sidebar ads :) thanks mate

Franklin Bishop April 23, 2009 at 6:47 pm

Yeah, what are you looking for?

Jorge Ledesma April 23, 2009 at 8:42 pm

Hey, thanks for replying, you have a great site and a great about page, well I’m kind of new blogging its only been 2 yrs on and off and I’ve decided to make a go with my site(this is strictly a hobby of mine, I’m actually a dentist) to increase my rss readers and maybe make a little money nothing serious but my goal is maybe a $500, I’d like to donate these monies to charity of mine. Anyway back to the question I’d like to have a few banners, I read on another site that the following banners are a must(what do you think) 125×125, 300×250, 468×60(which I’m sure you agree lol), 120×600, and a 260×32 so I’m thinking its a similar code, anyway I would appreciate any insight or help.

Thanks Franklin and again great site, to be honest, there are lot site that deal with your topic but your kind off captivated me, the style is smooth and kind off kicks your inquisitive side, so congrats good job, you got me.

Jorge

Franklin Bishop April 24, 2009 at 9:00 pm

I would use a plugin for 125×125 (which seem to be the best). I can do a tutorial for you tomorrow really quick. It will be best or a 468×60 which has worked wonders for me.

Nokia Mobile Talk April 24, 2009 at 9:56 am

I’m definitely doing this, any thoughts on the above comment – Jorge Ledesma, that’s me :)

Jen April 25, 2009 at 2:37 pm

Hi Franklin. Thanks so much for this code. For some reason it just won’t work on my site though. Any thoughts?

EverydayGuide May 1, 2009 at 11:44 am

Hi,

I came here from the thesis forum. Can you tell me how to place a 468×60 Google Adsense ad instead of a static image banner?

Adrian May 10, 2009 at 5:53 am

mee tooo

Ms. C May 11, 2009 at 11:21 am

Inside the div, put your AdSense code instead of the . Just put it between the opening and closing div tags. The css code should be the same.

(added spaces to the tags in hopes they’ll show up…)

Ms. C May 11, 2009 at 11:23 am

Ok, that didn’t show up. Trying again without the code. (You can delete my other comment…)

Just replace everything between the opening and closing div tags in the custom function code with your AdSense banner code. Styling should be the same.

Reddy May 12, 2009 at 9:46 am

Can you tell me how to place a 468×60 Google Adsense ad in the header???

johnwalker34 May 12, 2009 at 9:48 am

Can you please write a tutorial about it
thanks

fanari May 4, 2009 at 11:59 am

thanks for this tutorial :)

Brian May 12, 2009 at 9:45 am

hey
i want to know it, too

andrew May 21, 2009 at 3:13 pm

hey thanks – this is great. I’m getting it to show up, but i can’t make the ad in the header stationary. in other words, when i make my browser window smaller and larger, it moves the ad around.

do you know how to make it “stick” there?

Franklin Bishop May 22, 2009 at 10:57 am

Should already stick. Can you show me?

andrew May 22, 2009 at 11:47 am

Franklin – It’s my bad, I got it to work. Basically the “twist” was

position: absolute;

vs.

position: fixed;

I’m a nooob. :)

This tutorial rocked.

Mark McGuinness May 23, 2009 at 9:41 am

Thanks this is awesome! Just added a banner on my homepage.

the Unhygenius June 16, 2009 at 9:32 pm

Franklin— thanks for the tutorial.. i have it partially working.. im attempting to use this to put a hyper-linked banner ad [not adsense] into the header. i would like it to the right of the logo — which i have already replaced with an image. so far, the banner ad is scaling with opening and closing the window, independently of the rest of the blog. wheras yours moves as it should. im using the code you provided, except i have specified a BG image in the css [the banner ad] is this a common problem? what should i do?

the Unhygenius June 16, 2009 at 9:40 pm

heres the code i used to replace the blog title with a logo image… is this part of the problem perhaps?

thanks! — K

/* This line sets up our clickable background image based on the site title’s link */
/* DIY: Adjust the height & width attributes to reflect the actual size of your image */
/* DIY: Change the filename of your image to reflect the actual header’s file name */
.custom #header #logo a { display: block; height: 100px; width: 486px; background: url(‘images/annlogo_h.png’) no-repeat; outline: none; margin-top:10px;}

/* This line gets rid of the site title & tagline by casting them out to far left field */
.custom #header #logo, .custom #header #tagline { text-indent: -9999px; }

/* This line collapses the vertical space of the tagline so that there isn’t unnecessary white space after the header image */

/* This is a bit of a kludge, but it seems to work. */
.custom #header #tagline { height: 0; }

/* This line removes the padding from the header so that the background image sits close to the nav menu, the bottom border of the header, and the sides of the content */
.custom #header { padding: 0; }

Latest News August 1, 2009 at 5:44 am

Thanks for give great tips , i am searching from last one month and finaly get it and use it , So many Thanks for this Tips , we are using in header

Zdeno August 5, 2009 at 1:53 pm

Hi Franklin
Thanks for great tips about adding ad to header. Works great but i have small small problem. When i tested this with different resolutions, ad is moving and not align nice with right side of my site. Same thing when i open bookmarks on my left side in firefox. How can i fix this banner to stay in place and aligned with my right border with any resolution or screen size instead of floating around?
Thanks in advance

chris August 23, 2009 at 6:08 am

Nice tutorial Franklin. Worked great with my site.

Do you have any idea on how to make it a rotating banner?

Cheers

Magic Power Coffee August 29, 2009 at 8:50 am

thanks for the tutorial… awesome !!!

Comments on this entry are closed.

{ 5 trackbacks }

Previous post:

Next post: