How To: Use a Header Image with Thesis

There are a ton of things I love about Thesis, many of which I go over in my Why Thesis post. However, one thing that people often have trouble with is including a header image instead of just text. There are plenty of tutorials on how to do this out there, but many of them handle it just plain wrong. The biggest issue I have is that many tutorials advocate using this faulty line of code:

.custom #header #logo, .custom #header #tagline { text-indent: -9999px; }

No, no, no. This little snippet casts the text headline 9,999 pixels to the left, so it will never be seen. It technically works, but it’s more of a hack than a solution. One day, search engines may decide that they really don’t like the practice of hiding text this way, much like they don’t like white text on white background.

What’s the right way to get rid of the text?

Thesis has a built-in hook for exactly this purpose, though few people use it. This is the hook you’re looking for:

remove_action(‘thesis_hook_header’, ‘thesis_default_header’);

That gets rid of the header text correctly, instead of just hiding it. The next step is to actually add your header. This is the code:

function custom_header() { ?>
<div id=”headerlogo”>
<a href=”<?php bloginfo( ‘url’ ); ?>/”>
<img src=”<?php bloginfo(‘template_directory’) ?>/custom/images/header.jpg” alt=”Dont forget your alt text here” />
</a>
</div>
<?php }
add_action(‘thesis_hook_before_header’, ‘custom_header’);

Of course, you’ll need to make a header image, and upload it to the /custom/images directly of your Thesis installation.  So, to put it all together, just copy and paste this block of code into your custom_functions.php file:

function custom_header() { ?>
<div id=”headerlogo”>
<a href=”<?php bloginfo( ‘url’ ); ?>/”>
<img src=”<?php bloginfo(‘template_directory’) ?>/custom/images/header.jpg” alt=”Dont forget your alt text here” />
</a>
</div>
<?php }
add_action(‘thesis_hook_before_header’, ‘custom_header’);
remove_action(‘thesis_hook_header’, ‘thesis_default_header’);

That’s it.  One tiny block of code, and you have a clickable image header in Thesis.

Get Free Updates

If you enjoyed this article, you will definitely enjoy our others. Subscribe to the feed to get instantly updated for those awesome articles soon to come.

Share this article:

{ 3 comments… read them below or add one }

Margo February 25, 2010 at 9:18 am

I like this method better also. With the css hack its just background so you can’t add an alt tag or title tag. Good post!

Rob February 25, 2010 at 7:25 pm

Glad to help Margo. I know I’m not perfect at PHP / HTML / CSS, but I simply hate hacks. Especially hacks that could easily get you in trouble with search engines down the road.

Chuck June 28, 2010 at 7:15 am

Thank you for this clarification.
I use Thesis almost exclusively for my simple adsense websites. I have tried others but keep coming back to Thesis. For all it’s strong points the lure of a clickable header image remains a strong lure for other themes.
I haven’t tried it (your code) yet but your explanation is a lot easier read and I like the idea of “doing it the right way”

Thanks,

Chuck

Leave a Comment

Previous post:

Next post: