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.
Excellent! However, what if instead of removing the default divi sidebar, I then wanted to replace it with different sidebar content?
One plugin that might be helpful for doing this is WooSidebars: https://woocommerce.com/woosidebars/
This gave me an error:
Parse error: syntax error, unexpected ‘unset’ (T_UNSET)
Hey Andy! It sounds like a problem with the way you copied and pasted the code. I re-embedded the code using GitHubGist to make it easier for you to copy over. Want to try it again?
Hi Robert,
I’ve done this for bbpress, no errors but the sidebar remains….
The site I am doing this for is http://ghostware.org and the forums reside in http://ghostware.org/forums/
Hello Dick! It does not appear that your site is using a Divi child theme. The child theme is where the customizations happen and it appears that the main Divi theme is activated on your site, not a child theme of Divi.
Hi Robert,
Thanks for your prompt reply. Yes, for sure the site uses a child theme. All my sites have. I create a lot of wordpress sites but this is the first time I’ve installed bbpress for a customer. The child-theme name is mcdivi, and it’s active.
It appears that you may be mistaken. I don’t see “mcdivi” in the source of your page at ghostware.org anywhere. If you’re using a child theme named “mcdivi” on the site and it was active, we should be seeing “/themes/mcdivi/style.css” being loaded somewhere. Instead, all I see is “/themes/Divi/style.css”, what we would be seeing if Divi was the active theme instead of the child theme.
Hi Robert,
You are totally right, sorry, did not pay attention. It had the child-theme, but was apparently not activated. Now it is and works. Thanks for your help, I appreciate that.
No problem. Glad it’s working now! Keep up the good work. 🙂
I’m not clear on how to do this: 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
Hello Kimberly! This is usually done via FTP. Here’s a helpful article on creating and customizing child themes: https://www.smashingmagazine.com/2016/01/create-customize-wordpress-child-theme/
I am using a child theme. I’m just not sure what to copy where in my php to eliminate the Divi sidebar and include the bbpress sidebar.
Great! What you want, Kimberly, is a file named bbpress.php in your child theme folder that has the exact same contents as the page.php file from your Divi theme folder. The one change you’ll make to the bbpress.php file is to remove the “get_sidebar();” line near the end of the file.
I’m sorry to be so dense, but is this the code I’m supposed to be modifying?
}
<article id="post-” >
” . esc_html__( ‘Pages:’, ‘Divi’ ), ‘after’ => ” ) );
?>
If you’re using the latest version of Divi (3.0.34), you’ll find “get_sidebar();” on line 64 of “page.php”
Hi,
I have actually the opposite problem. Im using Beaver Builder and my BP profile page is full width without any sidebar and I have no idea how to asign sidebar. I suppose I have to create extra template with sidebar.
Any help with this?
Thank you!
Thanks a lot, works like a charm.
Just have to change:
if( is_buddypress() || is_bbpress() ) {
into:
if( is_bbpress() ) {
since I just use bbpress and was getting php fatal error
This is important. Thanks, Eric!
Hi, thanks so far. i changed this but still get an fatal error. any other ideas?
Thanks, Arno
Hi Arno, do you still have a fatal error ? I had fatal error but now it’s resolved, where did you put the code in your function.php ?
Is there any way to get rid of the side bar without creating a child theme? Is it possible for someone to create for me something I can copy and paste into the Diviv theme options custom CSS box that would work? Thanks!