The popular Divi 2 WordPress theme by Elegant Themes has easy, built-in controls for choosing how the sidebar works on posts and pages. However, if you install the latest BuddyPress 2.6 or bbPress 2.5 plugins to set up user forums or profiles, Divi displays the default right-hand sidebar with no option to change or remove it. This is unfortunate.
Thankfully, it’s easy to remove by changing one line in a template file and adding a few lines to your child theme’s functions.php file:
1. Remove the sidebar from the page template(s)
The first thing we need to do is to remove the get_sidebar() code from the bbPress and/or BuddyPress page templates. Both bbPress and BuddyPress have in-depth articles on how to override templates in a child theme. But for our purposes, it’s pretty simple:
- Make sure that you are using a child theme for Divi
- If you want to remove the sidebar from bbPress, copy the page.php from the Divi theme folder into your child theme folder and rename it to bbpress.php
- If you want to remove the sidebar from BuddyPress, copy the page.php from the Divi theme folder into your child theme folder and rename it to buddypress.php
- Edit both the bbpress.php and/or buddypress.php files that now reside in your Divi child theme folder and remove the “get_sidebar();” line near the end of the file.
2. Adjust body classes to correct Divi styling
We’ll now need to adjust the classes of the <body> tag so that Divi correctly styles bbPress and BuddyPress pages as fullwidth with no sidebar. This can be done by adding the following code to your child theme’s functions.php file: (By the way, the “<?php” line at the very top is not needed if you’re adding this to an existing “functions.php” file).
The above code adds a function to the body_class filter that detects if you’re on a buddypress or bbpress page. If you are, it removes any “et_right_sidebar”, “et_left_sidebar”, and “et_includes_sidebar” classes and instead inserts a “et_full_width_page” class.