There are many ways to modify the way the bbPress forums look like, styling changes, filters and actions and overriding the templates bbPress uses to render all the forums elements.
bbPress can work with any theme using something called ‘theme compatibility’ layer. It allows bbPress to use common ‘page.php’ template and embed inside the rendered content for forums. But, the default layout of the forum might not fit with every theme, and that is why bbPress can be completely changed by overriding and changing default templates that come with bbPress. And, that is something some theme use to modify the way bbPress looks and feels. Most theme don’t change the templates, but only styling. Still, some things can’t be changed without making modifications to templates.
Methods for the modifications
There are 3 ways to modify the look and feel of the bbPress forums.
- CSS styling: this is most common method to customize bbPress forums. It doesn’t affect the layout and the templates, only the styling is affected, allowing themes to adjust the forums to look more like the theme. Most themes with bbPress support are using this customization method.
- Filters and Actions: third party plugin developers can use actions and filters present through out bbPress and bbPress templates to control various aspects of the forums, add extra elements into forums and more. All plugins made for bbPress are using this customization method.
- Templates override: this method is used by some themes to change the layout of the forums by directly modifying the templates bbPress use to display forums, topics, replies and other elements. In theory, other plugins can do this, not just themes, because bbPress allows adding extra template storage locations (but, that is not in the scope of this tutorial).
bbPress templates are similar to theme templates, they are used to display all forums elements. These templates are combination of HTML and PHP, and they include a lot of filters and actions that can help plugin developers hooking into different template parts. For a lot of changes, using filters and actions is quite enough to make complex changes, and the only method that can do everything, is the modification of templates.
All default templates bbPress uses are located inside the bbPress plugin directory under ‘templates/default/bbpress’. There are 50+ templates there, and they use easy to follow naming scheme to help you find the template you need. But, good practice is to follow each template and make note when the template uses ‘bbp_get_template_part‘ functions to load different template parts.
To override the template in your theme, you should follow these simple rules:
- Make sure that your theme has a ‘bbpress‘ directory. All templates you override should go into this directory.
- Find the bbPress template you want to change in the bbPress plugin directory ‘templates/default/bbpress‘.
- Copy the template from bbPress directory into your theme ‘bbpress‘ directory.
Repeat steps 2 and 3 for all templates you need to change.
For instance, you want to make changes to the ‘form-topic.php‘ file. Default file is located in this directory: wp-content/plugins/bbpress/templates/default/bbpress/ and you need to copy it into your theme bbPress directory: wp-content/themes/theme-name/bbpress/.
When you make changes to bbPress templates, you should note the following:
- New bbPress versions often make changes to default templates. So, if your theme overrides a template from older version of the bbPress, when new bbPress is released, your override template might be lacking some new features added in latest version. When new bbPress is released, make sure you check the templates you override in your theme and adjust them for the new templates in bbPress.
- Do not remove any actions and filters from the templates you are changing (do_action and apply_filters function calls)! If you remove any of them, you are risking breaking some of the features in bbPress or features added by the third party plugins.