Login

Using Your Own Footer File

As of Thesis 1.5.1, you have the ability to replace Thesis’ footer with an entirely custom one through the use of filters. Don’t, however, expect to override the div#footer area as it is output before the footer file is processed. There is very little default output which can be overridden with a custom footer, but there is absolutely no limit on what can be added to the footer by creative customizers! The method for doing this is very simple.

First, you need a custom footer file. For our example, let’s assume you only want to replace the footer on search results, so create a file within your Thesis directory (not the custom folder, but Thesis’ main directory) and name it footer-search.php. You can change “search” to any word that you would want to use to describe your custom footer file. The rest of the structure must remain in tact.

Second, instruct WordPress to use your footer file rather than Thesis’ default by adding this bit to your custom_functions.php file within Thesis:

function search_footer($template) {
	if (is_search()) return 'search';
	else return $template;
}
add_filter('thesis_get_footer', 'search_footer');

What that custom function does is to tell WordPress that if we are on a search page, we want the “search” footer; otherwise, carry on as normal.

Getting WordPress to use footer-search.php is only part of the battle; the other part is knowing what your custom footer file should contain. Copying the Thesis default file is a start, but it isn’t too helpful for customization. Instead, use the following as a template for your own custom footers.

<?php # This line should be preserved as it is used to output footer scripts and styling fixes for IE, plus custom-added hook actions.
thesis_hook_after_html(); ?>

</body>
</html>

Give every category, every tag, every type of page on your site its very own custom footer. There’s really no limit to this other than imagination, especially when you consider that using this technique allows you to execute code between the closing HTML tags or even after all the markup has been sent.

Customizing your Thesis install in this way breaks the tradition of keeping all of your customizations within the custom/ directory. When you upgrade Thesis, you are responsible for preserving your custom footer files as well, otherwise WordPress will resort to Thesis’ default footer file or if for some reason even it is missing, WordPress’ Default theme’s footer file.