Archived topic
buddypress sidebar menu
3 replies · Started by Lim on January 27, 2021
Hi.
Good evening!
I searched for a similar code, but I couldn't find the exact code for buddypress, so please correct it a little bit.
What I want is to use the leftside bar in the buddy press.
----------------------------------------------------------------
add_filter( 'generate_sidebar_layout','tu_custom_bbpress_sidebar_layout' );
function tu_custom_bbpress_sidebar_layout( $layout )
{
// If we are on a bbpress page, set the sidebar
if ( function_exists( 'is_bbpress' ) && is_bbpress() )
return 'no-sidebar';
// Or else, set the regular layout
return $layout;
}
----------------------------------------------------------
please. change the code for buddypress.
I don't have any knowledge of code. I'm sorry.
Hi there,
I believe the condition you need is is_buddypress() instead of is_bbpress().
If you replace those instances in the code, it should work :)
Hi Tom.
I tried but no change.
This is my snipet code that you said.
----------------
add_filter( 'generate_sidebar_layout','tu_custom_bbpress_sidebar_layout' );
function tu_custom_bbpress_sidebar_layout( $layout )
{
// If we are on a bbpress page, set the sidebar
if ( function_exists( 'is_bbpress' ) && is_bbpress() )
return 'no-sidebar';
// Or else, set the regular layout
return $layout;
}
{
// If we are on a buddypress page, set the sidebar
if ( function_exists( ‘is_buddypress’) && is_buddypress() )
return ‘left-sidebar’;
// Or else, set the regular layout
return $layout;
}
---------------------------------------
I requested that I want to show the left sidebar in Buddypress not no-sidebar.
I don't know PHP so much that I'm not sure if I did what you said.
Please consider that non-developers also use the generate press.
I look forward to your kind and detailed reply.
Where in BuddyPress are you wanting this condition to apply to, ideally?
BuddyPress has tons of different conditionals for different areas in their plugin, which makes this sort of thing quite difficult.
This is the function: https://www.buddyboss.com/resources/reference/functions/is_buddypress/
And this should be the filter:
add_filter( 'generate_sidebar_layout', function( $layout ) {
if ( function_exists( 'is_buddypress' ) && is_buddypress() ) {
return 'left-sidebar';
}
return $layout;
} );