Updates, Tips & Tricks

Updates as Released, Plus My Personal Collection Of WordPress Best Practices

Fix bbPress Search in Canvas Theme

17 December

If you’re having trouble with bbPress searching in the Canvas theme you can try the following technique to get it resolved.

Download the file bbpress.php from https://gist.github.com/mattyza/1b01583441b11c8d04d0

Place the following code in your functions.php file:

//https://gist.github.com/mattyza/f210cadb7f70188d513d
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()

This will resolve the loop-search.php naming conflict and force bbpress.php to be used on bbpress frontend screens and prevent theme and child themes from being searched for bbpress template files.

No comments yet.

Leave a Reply