[Resolved] Enable sidebar in BBpress topics and disable them in WP single post

Home Forums Support [Resolved] Enable sidebar in BBpress topics and disable them in WP single post

Home Forums Support Enable sidebar in BBpress topics and disable them in WP single post

  • This topic has 5 replies, 2 voices, and was last updated 8 years ago by Tom.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #183301
    Philip

    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?

    #183335
    Tom
    Lead Developer
    Lead Developer

    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/

    #183489
    Philip

    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

    #183491
    Tom
    Lead Developer
    Lead Developer

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

    #183493
    Philip

    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!

    #183501
    Tom
    Lead Developer
    Lead Developer

    Awesome, you’re welcome 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.