Buddypress Sidebar, full width site

Hello team,

I want a right sidebar on only buddy press pages for one of my sites. The rest of the site needs to be full width, because if it is not, the sidebar also shows up in places where I do not want it.
How can I achieve this? I found this piece of code below that I put into my child theme under,
but it does not work, I am using Ethos and this was made for the Renew stack, so maybe that is why it does not show? Could you please help me out? I have been at this one particular thing for many hours and it is just not working.

This is the code:

<?php

// =============================================================================
// VIEWS/RENEW/WP-BUDDYPRESS.PHP
// -----------------------------------------------------------------------------
// BuddyPress output for Renew.
// =============================================================================

?>

<?php get_header(); ?>

**

**
**
**

** <?php while ( have_posts() ) : the_post(); ?>**
** <?php x_get_view( 'global', '_content', 'buddypress' ); ?>**
** <?php endwhile; ?>**

**

**

**

**

**

**

<?php get_footer(); ?>
This is the topic where I found the code:
https://theme.co/archive/forums/topic/buddypress-sidebar/

I am also adding my credentials in a note.

Thank you,

Liesje

Hello Liesje,

Thanks for writing in!

I have checked your site and in X > Theme Options > Layout and Design > Content Layout, you have set to “Fullwidth”. This means that all of your site pages will always be fullwidth. No matter what you do with the BuddyPress template in your child theme, it will always be fullwidth.

To fully modify the page layout and have a sidebar on the right side, you will have to override the fullwidth settings in the theme options. The only way to do that is to add a custom PHP function in your child theme’s functions.php file. You can take a look at this thread here: Force full-width post on post options for specific tag

We will be basing our code in the thread. In your case, you will have to create your own custom PHP function and set a content-sidebar layout when the page is BuddyPress pages. Since the child theme is set up, please add the following code in your child theme’s functions.php file

// Display sidebars in Buddypress pages
// =============================================================================
function add_sidebars_buddypress($contents) {
  if ( x_is_buddypress() ) {
    $contents = 'content-sidebar';
  }
  
  return $contents;
}
add_filter('x_option_x_layout_content', 'add_sidebars_buddypress');
// =============================================================================

By the way, you can remove the wp-buddypress.php in framework/views/wp-buddypress.php because it does not work nor in the right location. You do not need it because of the override code above for the layout of the BuddyPress pages.

Please be advised that custom modification is way beyond the scope of our support. The given code above is an example that serves as a guide in doing your modifications.

We would love to know if this has worked for you. Thank you.

Hello Rue Nel!

Thank you so much for the help, but I freaked out trying to figure it out and realized that this is way beyond my scope, so I looked into other options and I actually found an easy way to achieve what I wanted, that only required a little bit of code.
What I did not tell you is that the reason I wanted to have sidebars only on the buddypress pages is because they were showing up on the custom post pages of a plugin I am using called visual portfolio. I found how to target these pages with the css below and so changed the general setting to content left sidebar right for the whole site et voila :slight_smile:
I know now to give the whole story next time because you would have given me that simple solution as well if you had known.
In any case, I learned my lesson, thanks for trying and for always being there with this amazing support!

what worked in the end:

/* Removing Sidebar From the Single Portfolio item */
.single-portfolio .x-main {
width: 100%;
float: none;
}

.single-portfolio .x-sidebar {
display: none !important;
}

Hi Mitica,

Glad you found the solution that works for you and thank you for updating us!

Cheers.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.