Site logo

Archived topic

Enable sidebar in BBpress topics and disable them in WP single post

5 replies · Started by Philip on March 31, 2016

Viewing posts 1–6 of 6

Hello
I wanted to do this long time ago because is very essential for my site.
The idea is that i want to enable sidebar widgets in bbpress forums,topics,replies but disable them in wordpress single post that is located in each category.
When i enable Single Post Sidebar Layout the sidebar appear in both WP single post and every topic in bbpress forums,topics,replies now i need somehow to disable sidebar in WP single post so sidebar widgets remain in bbpress forums only. I need this because in each WP post i upload full size photo and members can't save that is why sidebar widgets in that place are not needed.
Can you help with this please,some code maybe?

Hi there,

You can do something like this:

add_filter( 'generate_sidebar_layout','generate_custom_bbpress_sidebar_layout' );
function generate_custom_bbpress_sidebar_layout( $layout )
{
 	// If we are on a bbpress page, set the sidebar
 	if ( is_bbpress() )
 	 	return 'right-sidebar';

 	// Or else, set the regular layout
 	return $layout;

 }

Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

I have added at the end of function.php but give error.
Parse error: syntax error, unexpected '}' in /home/content/p3pnexwpnas02_data02/24/2579724/html/wp-content/themes/generatepress_child/functions.php on line 44

Can you post the entire contents of that file in a pastebin (pastebin.com) and share it with me?

The code is working perfect i'm happy now.
There was one of this } between codes removed and it works,also i had to leave Layout single post Content No Sidebars and the code is working.
Thank you for all the help!

Awesome, you're welcome :)

This archived topic is closed to new replies.