Thesis Sticky Footer

by Matt Hodder on August 10, 2009 | 26 Comments| Filed under: Customization

stickyfooter

Thesis is what you make it

Lately I have been witnessing more and more complex and beautiful designs throughout the community. Thesis is really what you make it. I’ve found I can work away at a design mock up in Photoshop, and no matter what I come up with, I can replicate it in Thesis. Of course, as designs get more complex so does the development. Thesis can’t do everything right out of the box.

How to stick your Thesis footer to the bottom of the page

On it’s own, with no custom tweaks, the Thesis footer looks and feels great. It’s exactly where one would expect it to be in terms of placement. However, while designs get more complex and more elements are thrown into the mix things tend to not sit as well. Below is a shot of the standard out of the box design of Thesis. I’ve deliberately included a small amount of content and a tiny set of widgets for the example.

thesis-default

As you can see everything looks and feels great. But what if we wanted to mix things up and add a light grey background to the footer? Well let’s try exactly that and see what happens:

thesis-default-footer-shaded

Now the placement of that footer isn’t working so well. We would expect the footer to be shot to the bottom of the page no matter the content and window size, or at least have anything below the footer the same colour. Of course, if we had more content we would get the desired effect- however that’s not always the case. So what now? Alas, Thesis can’t be at two places at once, so we are going to have to leave the defaults, and tweak our custom files.

The CSS

I’ve based the CSS off one of the most widely used sticky footer solutions in web design, The CSS Sticky Footer by Ryan Fait. Taking his original CSS we are going to work it into our thesis site. First, open up the custom.css file located in the custom folder (found in the Thesis theme directory). If it’s named custom-sample, simply rename it to custom and proceed. Make sure you back up anything in that folder before continuing.

Once you have custom.css open, pop this code into the file:

html, .custom {
 height: 100%;
}
.custom .wrapper {
 min-height: 100%;
 height: auto !important;
 height: 100%;
 margin: 0 auto -100px; /* the bottom margin is the negative value of the footer's height */
}
.custom #footer_area, .custom .push {
 height: 100px; /* .push must be the same height as .footer */
}

Thankfully, that small bit of code is all you need in terms of CSS. Obviously you can change the height of the footer to your preference. Make sure if you change the height, to also change the .custom .wrapper margin as well (as shown in the comments). Right now you won’t get anything if you tried to refresh your Thesis page- as we haven’t created the wrapper or push containers that are referenced in the CSS.

The PHP

In that same custom folder you should find a separate file called custom_functions.php. Open that up and paste the code below:

add_action('thesis_hook_after_content_area', 'div_push');
add_action('thesis_hook_before_html', 'div_wrapper_start');
add_action('thesis_hook_after_content_area', 'div_wrapper_close');

function div_push() {
 ?>
 <div class="push"></div>
 <?php
}

function div_wrapper_start() {
 ?>
 <div class="wrapper">
 <?php
}

function div_wrapper_close() {
 ?>
 </div>
 <?php
}

Basically this code is creating some new layout containers for the site. The header and content area will now be wrapped in a wrapper container, with a push container placed inside. Our CSS now has it’s elements to call on and have something to “push” to the bottom of the page.

We’re Done!

Yep, that’s it. If you have a very content lacking site you now have no need to worry. If you refresh your site, you should have something that looks like this no matter the window size:

thesis-fixed-footer-shaded

The only thing you may want to change, like I said before, is the height. Other then that, you’re good to launch your site and see your changes. This technique should work in all major browsers and even IE6. If you have any questions, fire them in the comments section below.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Ping.fm
  • Reddit
  • Tumblr
  • StumbleUpon
  • SphereIt
  • Twitter
Matt Hodder is a freelance web developer from Prince Edward Island, Canada. He was thrown into the Thesis world headfirst on a couple projects, and has since adapted it as one of his key tools of development. Make sure to follow Matt on twitter at @matthodder, or on his personal site www.matthodder.com.

{ 26 comments… read them below or add one }

Ryan Beale August 10, 2009 at 2:48 pm

Matt,

This is an excellent WP Thesis Tutorial! I’m excited to customize the footer of my site using this tutorial! Thanks a lot!

@RBeale

Matt Hodder August 11, 2009 at 2:02 am

@Ryan

Thanks Ryan.. Glad it helped.. I’m hoping to write regularly on Thesis- but it’s tough to come up with original tutorials.

Bernardo Kuri August 11, 2009 at 4:27 pm

Thanks! It would be nice to see an option for this in the Thesis control panel on a future version. Keep up the good work!

Bill August 16, 2009 at 11:30 am

Thanks for the great tutorial. I put three lines of text on a full width page to test this tutorial out. My footer doesn’t show at the bottom of the monitor. I have to scroll to see the footer. How can I make the bottom of the footer stay on the monitor at all times when there is only a couple of lines of text on a page?

Matt Hodder August 16, 2009 at 4:18 pm

@Bernardo
Thanks for the comment. We’ll keep it in mind for future skins.

@Bill
So that the footer is actually overlaying the content and floating at the bottom of the window- like this site? That would be a totally different approach. Check back and I’ll try to do a tutorial on that later.

Bernardo Kuri August 17, 2009 at 8:35 pm

@Matt: I have a another question… Why are there two different functions pointing to the same hook (thesis_hook_after_content_area)? Doesn’t one action override the other? Thanks again!

Matt Hodder August 17, 2009 at 8:49 pm

@Bernardo
They just get placed in order (one after the other rather then overwritten). They could be combined into one function but I find it more organized this way- but no technical difference.

stan August 19, 2009 at 12:39 am

hi matt,
When I create pages like: about, contact, privacy, sitemap they show up in sidebar. I am using 2 column thesis theme.

I want to put them either in nav bar on top OR at footer.
The way it looks now, they are in sidebar and nav bar.

How to solve this. Thanks.

Matt Hodder August 19, 2009 at 10:48 am

@stan

You must have a widget enabled for pages in the sidebar. You can get rid of it through your dashboard, appearance> widgets.

To have them show up in the nav bar at the top you have to go into (in the WP dashboard) Thesis Options > Navigation Menu > Select pages to include in nav menu: … where you will select what you want to show up in the nav.

Hope that helps- If you have any more questions, submit them in the Thesisthemes support forum.

Mat packer September 9, 2009 at 1:10 am

Nice tut, easy to follow.

Matt Hodder September 9, 2009 at 11:18 am

Thanks Mat.

Caleb September 18, 2009 at 12:28 am

Hey Matt,

I’m having a hard time putting the footer. I was wondering how I could do it similar to yours but featuring our most recent blog posts instead.

Problem is, my custom.css file is not working!

Jayson T. Cote September 28, 2009 at 12:49 am

Matt, sweet technique! I am avid Thesis developer as well and would like to apply the same technique to my sidebar to achieve 100% height, but no matter it doesn’t happen. Have any CSS and functions to apply to the sidebar to expand 100% height?
Thanks Matt.
All the best,
Jayson
http://wpcoop.org
http://groundupmedia.com

Matt Hodder October 1, 2009 at 9:39 pm

@Jayson

Usually I just set the background of the #content_box to an image, to simulate 100% height. That’s worked for me, and I think things would get over complicated trying to get 100% height otherwise.

Eddie Gear October 2, 2009 at 11:04 am

Hey Matt,

This is awesome! As you said it, Thesis is what you make of it. I do not and cannot afford to get a Thesis theme, However I managed to custom design one myself. Can you help as to how I can add the same to my theme.

Cheers,
Eddie Gear

Matt Hodder October 5, 2009 at 2:22 pm

@Eddie,

This is a Thesis tutorial, so it’ll be quite different for another wordpress theme (especially one I have no knowledge of). Try this link and see if it can help: http://ryanfait.com/resources/footer-stick-to-bottom-of-page/

Bernardo Kuri October 10, 2009 at 8:02 am

I just tried implementing this tip using Thesis 1.6b2, but it’s not working. If I place the “push” div inside the “thesis_hook_after_content_area” hook, Thesis seems to skip it (almost as if the hook is ignored). Placing said div on any other hook seems to work.

Has someone made this work in Thesis 1.6 yet? TIA

Matt Hodder October 13, 2009 at 8:17 pm

Once 1.6 is officially released I’ll update the tutorial.

Joe October 16, 2009 at 3:11 am

Great Tutorial Matt,

I seem to have an issue in Internet explorer though.. there is a large white space appearing under the footer.. any ideas?

Joe

Alistair November 13, 2009 at 5:49 am

Thanks Matt,

Explained exactly what I wanted, clearly and concise,

Asim November 23, 2009 at 2:55 pm

Matt please update it for Thesis 1.6

Matt Hodder November 23, 2009 at 5:23 pm

Asim,

Everything should be working with 1.6 just fine. I’ve just tested and didn’t have to make any changes. Let me know what’s not working for you.

Tanya December 5, 2009 at 11:52 am

Greetings Matt. I like the way you customized your footer with black and links going down. Will that be okay if you can let me know how you did it. Many thanks in advance.

Tanya

Matt Hodder December 5, 2009 at 4:00 pm

Tanya,

There’s a great tutorial here: http://www.kristarella.com/2008/11/thesis-footers-101/

Tanya December 6, 2009 at 6:54 pm

Thanks Matt

I have seen Kris’s footer tutorial before and she is one excellent tutor. I tried following her instructions and yet still am facing a few problems.

If it is okay with you, could you email me how you coded your custom.css and the custom functions and how the links were created.

Thanks again

Tanya

P/S Sorry to sound silly, but I have been looking for something like how you did yours!

Matt Hodder December 6, 2009 at 11:01 pm

Tanya,

We can’t supply you the code for our site, as its part of our original Thesis site, and we wouldn’t appreciate someone just copying our code/style.

It would take quite a bit of time to detail how we did the custom footer, and we have tons of original code in the custom_functions file.

If you want something similar, you can hire us to do it:
http://thesisthemes.com/request-a-quote/

or try the DIYthemes forums for help:
http://diythemes.com/forums/index.php

Leave a Comment

Comments are not a place to request support or report bugs, please use the support forum only to get help with our Thesis skins.


Previous post: How to Troubleshoot Your Code

Next post: Skins Updated For Thesis 1.6