How To Make A Rotating Header Image In Thesis

by Matt on March 5, 2010

When Chris Pearson, the creator of Thesis, recently redesigned Pearsonified.com on Thesis, he did something amazingly cool: he put rotating images in his header area.

Well, I was so inspired by his design that I wanted to figure out how he did it. It turns out that putting rotating images in your header is extremely easy.

On the backside.

Well, let’s get started. From the WordPress Dashboard, go to Thesis Options -> Design Options -> Feature Box.

In this tutorial, I am setting the Feature Box to “Full Width Above Content And Sidebars.” It is completely up to you whether you chose to show the rotator on every page or just the home page.

The Code

Let’s start with the Custom.CSS. I just want to warn you right now: THIS IS SUPER EASY!

Copy and paste the following into your Custom.CSS:

.custom #feature_box { padding: 0; border: none; }
	.custom #feature_box img { display: block; }

Wow! That’s it, folks. Ok, now let’s knock out the Custom_Functions.PHP part of this. Again, don’t be shocked when you see how unbelievably simple this is.

function header_rotator() {
echo thesis_image_rotator();
}
add_action('thesis_hook_feature_box','header_rotator');

Seriously, that is all. Unreal how simple that is, isn’t it?

Purchase or Upgrade to the Thesis Developer’s Option Today!

Add an Anchor Tag

Let’s say that you want to add an anchor tag, <a>, around the rotating image. Simply put this in your custom_functions.php file instead of what’s above:

function header_rotator() {
?><a href="http://addressgoeshere.com"><?php
echo thesis_image_rotator();
?></a><?php
}
add_action('thesis_hook_feature_box','header_rotator');

Just add the address you want to link to, and call it a day ;)

What about the images?

To get the images to line up perfectly you need to know the width of your site. If you use the Firebug plugin for Firefox or Google Chrome, you’ll have no problem finding out the width. Just remember that if you have page padding (as in the <div class=”page”>), you need to exclude that from the width calculation.

Also, I recommend making the images the same height so that the layout doesn’t shift on refreshes.

Oh, yeah. Don’t forget to Upgrade to the Developer Option! You will never regret it!

{ 3 trackbacks }

{ 48 comments… read them below or add one }

Richard Barratt March 8, 2010 at 9:22 am

Hi Matt

Thank you for showing me this link on Twitter the other day.

To everyone reading – Matt is right, this is one of the easiest and quickest mods you’ll ever do with Thesis.

Thanks again

Reply

Matt March 8, 2010 at 12:04 pm

@Richard
Thanks, man!

Reply

Dan March 13, 2010 at 10:56 pm

Thanks for the tutorial, easy to understand and turned out great!

Reply

Dan March 16, 2010 at 9:59 pm

Hey Matt,

Great tutorial, adds a lot to the site. I was wondering if you’re planning on writing another tutorial for a rotating feature gallery that’s linked to latest posts (like what you have on your homepage)?

Reply

Loren Nason March 20, 2010 at 1:24 am

Would it be possible to do this not in the header but below the navigation bar taking up the full width of the site. Then here is the kicker..

Lay a form on top of it

Similar to this site http://www.atproperties.com/

Reply

Matt March 23, 2010 at 12:31 pm

@Loren
That is quite a different thing. You’d need to have a CSS background image rotator. I’ll look into that, though.

Reply

Loren Nason July 28, 2010 at 11:55 pm

Completely forgot about you replying to me. I did figure it out but the client didn’t like it.. I’ll have to pull the code out of the page I used and do a tutorial on it

Reply

Ronald March 21, 2010 at 12:49 pm

This is cool.

But what if I want to do the rotating header image AND use the multimedia box to show a youtube video.

Can this work with both going on at once?

Reply

Matt March 21, 2010 at 2:24 pm

@Ronald
That’s no problem. Just make the changes in the multimedia box. Should have absolutely no effect on the rotator.

Reply

Rick Anderson March 21, 2010 at 6:34 pm

Very nice tutorial.

Reply

Willie Jackson March 23, 2010 at 4:39 pm

Hey Matt-

1. Is it possible to make these images clickable?
2. The name of the function is misspelled in this post, just FYI.
3. Is there a reason you don’t have the Reply button enabled in the comments? Just curious.
4. The “Subscribe to comments” plugin might be helpful when n00bs like me leave comments and want to check back when you’ve answered :-D

Reply

Matt March 24, 2010 at 11:24 am

@Willie
Thanks Willie!

Reply

Dan March 28, 2010 at 1:24 pm

Hey Matt,

I put the code in and it worked great the first time. I took it out for a few days because I was playing around with my header, but decided to put it in again – now it’s not working properly!

See the gray bar on the right side of the feature box? I resized my header and the feature box pictures from 979 to 969 px, but it seems as though the feature box wants to stay at 979…any idea how to fix this?

Reply

Dan March 28, 2010 at 1:36 pm

I just resized the sidebars and that took care of it….sorry for the false alarm and thanks again for putting these tutorials together, they’ve been incredibly helpful

Reply

Matt March 28, 2010 at 1:41 pm

@Dan
It looks fine to me. Not sure what you’re seeing. Interesting blog, btw ;)

Reply

Kopepasah April 10, 2010 at 1:25 am

Does this work if you are already using the multimedia box for something else?

Reply

Matt April 10, 2010 at 1:21 pm

@Kopepasah
This uses the feature box, not the multimedia box.

Reply

Ben April 19, 2010 at 2:40 pm

This worked great!

I’m wondering how to move the nav menu below the rotating header.

Any advice?

Thanks,

Ben

Reply

Merrick April 23, 2010 at 6:51 pm

hi, so i followed your instructions but still have padding and a gray color in the feature box. please let me no how to correct this. thanks

Reply

Matt April 27, 2010 at 12:27 pm

Not seeing that problem on your site, but the feature box does have padding by default.

Reply

Doug May 8, 2010 at 2:16 pm

Wow, I’ve been using Thesis tutorials for some time and yours is far and away the clearest and easiest to follow. Question: Is there a way to make the images auto-rotate rather than on a browser refresh? Thanks again!

Reply

Justin May 8, 2010 at 7:13 pm

I’m looking for the same solution, how to make the images auto-rotate so a browser refresh is not required. Is there a tutorial anyone can point to?

Thanks.

–Justin

Reply

Matt May 9, 2010 at 12:19 pm

I originally answered your question thinking you wanted to use the rotator pictures and PHP. You could use this instead: http://thesistutor.com/how-to-make-a-jquery-image-slideshow-in-thesis/

Reply

Philly June 1, 2010 at 6:52 pm

Great tutorial! How would I go about using the feature box to take up only half the header?

I want to have my logo image on the left and the feature box with rotating images on the right in the header. Is there a simple way to do this?

Reply

Nicole June 16, 2010 at 4:04 pm

Hi Matt,

Wondering if something has changed? I have the latest version of Thesis and followed your tutorial step by step, but I’m ending up with a border on the header image – tried making it larger/smaller and resizing the columns – no luck getting rid of it.

Check out http://www.bamboogreenhomes.com and tell me where I’m going wrong Oh Thesis God.

Cheers,
Nicole

Reply

Randolph Eustace-Walden July 1, 2010 at 1:55 pm

Hi Matt,

Excellent tut! A question, though.

I have Featured Content Gallery inside my Feature box and it works like a hot damn. However, it’s not centered – it’s flush left. The layout.css has symetrical padding (1.1em left and right) for the Feature Box which to me says, ‘centered’. Yes, I can mess with the left padding to make it ‘appear’ centered, but that doesn’t make any sense.

Thoughts? Ideas? Thanks.

Randy

Reply

Matt July 4, 2010 at 3:49 am

Adjusting padding to center something is indeed centering.

Reply

Cori July 5, 2010 at 9:56 pm

Hello Matt,

I have the same question as Philly. Logo to the left, rotating images to the right. I already have the logo in place via custom css and custom functions.php, not sure what to do next. I’ve seen others using a banner idea…just being careful with a client’s site.

Thanks

Reply

Lars A. Dale July 8, 2010 at 6:52 am

Hey Matt,

Excellent tutorial, just what I needed! :)

A couple of things I think you should know though:
There is an error in the ‘Add an Anchor Tag’ script, line #4 should look like this:

?><?php

Also, since I had moved my navbar below the header area, it appeared inside the featurebox when I used your method. Instead, I turned the feature box off in the settings and added the feature box using the header hook , like this:

add_action('thesis_hook_header', 'thesis_feature_box');

Of course, this only works if you want the rotating header sitewide..

You´re welcome to check out http://lunde.x10hosting.com/pro to see how it turned out. Thanks again! :)

Reply

Andrew August 16, 2010 at 10:04 pm

Thanks for the update to the code – I used the code to add in the rotating images and it worked fine. Then I tried to change to use the “add an anchor tag” and have the following error that I cannot seem to get rid of no matter what I do in the customer file editor: Fatal error: Cannot redeclare header_rotator() (previously declared in /home/***/public_html/wp-content/themes/thesis_17/custom/custom_functions.php:39) in /***/public_html/wp-content/themes/thesis_17/custom/custom_functions.php on line 47

How can I fix this?!
Thanks for the great tutorial!

Reply

Lars A. Dale July 8, 2010 at 6:59 am

Hmm, it seems the “close a” tag was stripped from within the “code” statement in my comment..

What I meant to say though, is that <?php is missing after you close the a-tag on line 4, which produces a fatal error if you just copy and paste the code like I did..

..Again, thanks for the help!

Reply

Matt July 8, 2010 at 11:53 pm

Nice spot on that. Thanks!

Also, if you need to add the feature box in the manner you described, and only want it on the homepage, you would do the following:

function header_rotator() {
if (is_home || is_front_page()) {
//the code from the tutorial goes here
}}

The important part is that you remember two curly brackets at the end.

Reply

Garry July 24, 2010 at 4:24 am

Hi Matt,

I have a quick couple of questions but they are also an urgent as I am trying to get my site up live this weekend if possible… I have the full with feature images working with no issue which is due to your clear instruction. I would really like to have then auto rotate rather then just on a refresh.. can you tell me how to do this ( hopefully this is simple ). and then two how can i make each image clickable to an individual url… just like you do on the front of your site which looks great.
P.S. The first question is really my most urgent, i am not a programmer and I cannot work this out, thanks in advance Matt

Reply

Matt July 25, 2010 at 1:25 am

You can hire me to help you, or use this tutorial to achieve what you want.

Reply

Kacia @ Coconut Robot August 9, 2010 at 11:09 pm

hi!
i’m a total newbie – and probably an idiot too ;o( I am trying thesis in my test.coconutrobot site – and here is my dumb question…ready?

Where do I store the images for the rotating image header? I put the PHP in the Hook Plugin – is that okay?

thanks!

Reply

Amir August 26, 2010 at 1:34 am

Hi Matt,

Thanks for the tutorial.. Really great!
I have some questions, Is it possible to have rotating headers on the home page and have different header assigned to each other page? Can you teach me how to do that?

Thanks!

Reply

sam September 10, 2010 at 4:31 pm

Hi,

Great to see you are pisces (the birthday post) ! Thanks for the tutorial, it really helped me!. Could you tell me how can I remove padding on my left of feature box? Tried to get ti out for looooong time . could not get it done :(

Reply

John September 15, 2010 at 9:21 am

Hi,
Spent ages trying to find out how to do this and eventually found your site.
Thanks for that, I also added alt and title tags to the images for SEO

Reply

Chris Jaeger October 9, 2010 at 5:51 pm

Many THANKS. If you were here, I’d buy you a Sam Adams Octoberfest!

Reply

laura December 2, 2010 at 11:36 am

Hi Matt,

Great tutorial!

I seem to have missed something though as I have a white space at the left and I have spent all afternoon trying to get rid of it and it won’t go away. can you help please?

Laura

Reply

Laura December 2, 2010 at 11:37 am

forgot to add the web address: http://weddingsphotographerkent.com/

Reply

Matt December 5, 2010 at 7:16 pm

that is your page padding, adjustable from within the thesis design options->site layout->outer page padding. set yours to zero.

Reply

Laura December 6, 2010 at 7:41 am

Hi Matt,

Thanks for getting back to me.

The problem I have is that I want the padding on the text, just not on the header.

Reply

Tony January 21, 2011 at 8:56 pm

What if you want a specific header image called out for certain pages? Can you use the Thesis custom fields to display a certain image?

Reply

Ali April 21, 2011 at 2:19 pm

Hi, I used this tutorial, and it works great, How do i then move the created feature box into the header space?i want to have a logo image to the left and then my sized feature box to the floated to the right of it. i have the horizontal alignment working but i can figure out how to move the feature box out of its default hook into the header area. any help would be greatly appreciated.

Reply

Edward Steve July 27, 2011 at 10:23 am

Thanks. Nice trick. I’d like to apply it soon. You made it quit easy.

Reply

Elliot July 28, 2011 at 1:34 pm

Hey Matt! Great tutorials. I was wondering the same thing as Ali and Philly. Is there a way to position the featurebox within the header, next to a static logo?? Would love your feedback on this!

Reply

vvalenciA January 4, 2012 at 11:33 pm

HOW CAN I PUT THE MENU ABOVE THE GALLERY WITH THE LOGO STAY IN TOP.

Reply

Leave a Comment

Previous post:

Next post: