Hacking Thesis Custom Template Functionality

I recently ran into a problem making FoxyShop compatible with the WordPress theme Thesis. I have to start out saying that I really don’t like WordPress theme frameworks that unhook all the wonderful things that make WordPress so flexible and easy to use. The header and footer functionality is something that many plugin developers rely on and unhooking it in favor of a proprietary method is something that can be very difficult to work around.

The Problem

FoxyShop uses the template _include filter to utilize its own template files. Thesis doesn’t use header.php and footer.php but instead uses its own proprietary functionality to place template elements on the page. This results in pages that don’t initiate thesis functions and subsequently don’t show any of the website elements (header, footer, sidebars).

The Solution

I’ve tried to use the Thesis custom template hook but it’s never worked right. The solution that I finally found involved wrapping the custom page content in a function and loading in the thesis_hook_before_content action. This seems to work well:

function foxyshop_single_category_function() {
//single category template content displays here

The Problem, Part 2

Because this is just getting inserted before the content, it still shows the page content and Thesis either tries to redisplay content or give an error warning about a missing page, etc. There’s no way to turn that off without hacking the core (which is really not the point).

The Solution, Part 2

I finally hit upon a solution which feels like a real “hack” but works very nicely. At the end of my display function, I tap into the global $wp_query and reset some variables to make WordPress/Thesis think that the page is a 404 page and then I remove the 404 actions so nothing gets displayed, essentially ending the content display box:

function foxyshop_single_category_function() {
//template content displays here

global $wp_query;
$wp_query->is_tax = false;
$wp_query->is_page = false;
$wp_query->is_home = false;
$wp_query->is_archive = false;
$wp_query->is_404 = true;


If you are having trouble with this, do a print_r($wp_query); to determine what WordPress thinks your page is so that you can turn that particular variable off.

Leave a Reply