Skip to content

Instantly share code, notes, and snippets.

@mattyza
Created May 10, 2013 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattyza/f210cadb7f70188d513d to your computer and use it in GitHub Desktop.
Save mattyza/f210cadb7f70188d513d to your computer and use it in GitHub Desktop.
Custom template loader logic, to work in conjunction with bbpress.php, in the Canvas theme by WooThemes.
add_filter( 'template_include', 'woo_custom_maybe_load_bbpress_tpl', 99 );
function woo_custom_maybe_load_bbpress_tpl ( $tpl ) {
if ( function_exists( 'is_bbpress' ) && is_bbpress() ) {
$tpl = locate_template( 'bbpress.php' );
}
return $tpl;
} // End woo_custom_maybe_load_bbpress_tpl()
add_filter( 'bbp_get_template_stack', 'woo_custom_deregister_bbpress_template_stack' );
function woo_custom_deregister_bbpress_template_stack ( $stack ) {
if ( 0 < count( $stack ) ) {
$stylesheet_dir = get_stylesheet_directory();
$template_dir = get_template_directory();
foreach ( $stack as $k => $v ) {
if ( $stylesheet_dir == $v || $template_dir == $v ) {
unset( $stack[$k] );
}
}
}
return $stack;
} // End woo_custom_deregister_bbpress_template_stack()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment