How to make Patch work with bbPress

By default, the way we designed the theme does not allow for the bbPress plugin to work to its full capabilities.

But have no worries, there’s a simple fix that can ensure you can use both products with ease.

Here’s what you need to do:

  1. First off, make sure you install the Patch Child theme. This ensures that all of the extra code you need won’t be removed when we release a new theme update.
  2. Navigate to Appearance → Theme Editor → make sure the Patch Child theme is selected
  3. Click the functions.php file → scroll to the bottom of the screen (in the code editor) → and paste the code below:
/*Fix integration with BBPress*/
function alter_post_classes( $classes ) {
    if ( function_exists( 'is_bbpress' ) && is_bbpress() ) {
        if ( ( $key = array_search( 'entry-card  js-masonry-item', $classes ) ) !== false ) {
            unset( $classes[ $key ] );
        }
    }

    return $classes;
}
add_filter( 'post_class', 'alter_post_classes', 20 );

function alter_body_class( $classes ) {

	if ( function_exists( 'is_bbpress' ) && is_bbpress() ) {
		if ( ( $key = array_search( 'archive', $classes ) ) !== false ) {
			unset( $classes[ $key ] );
            $classes[] = 'page';
		}
	}

	return $classes;
}
add_filter( 'body_class', 'alter_body_class', 999 );
  1. Click Update file and that’s it.

Here’s a helpful image:

Instructions to add custom code for bbPress to work with Patch
Updated on February 9, 2022

Can't find what you’re looking for? Ask a human.

We're a small team of real people providing real help. Send us an email at [email protected] and we will give you a helping hand.