Ask your WordPress questions! Pay money and get answers fast! (more info)

Add a sidebar on bbpress forum

Hello,
I have a personalized theme and I installed bbpress plugin with the intent to create a forum.

I want a sidebar for this forum (all pages of the forum).

Now I created via function.php the personalized sidebar as explained here
https://codex.bbpress.org/layout-and-functionality-examples-you-can-use/#26-creating-a-bbpress-specific-sidebar

[point 26]



function rkk_widgets_init() {

register_sidebar( array(
'name' => __( 'bbPress Sidebar', 'rkk' ),
'id' => 'bbp-sidebar',
'description' => __( 'A sidebar that only appears on bbPress pages', 'rkk' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}

add_action( 'widgets_init', 'rkk_widgets_init' );




However I have problems to set the second part, that is the code in the sidebar.php.



<?php if ( is_active_sidebar( 'sidebar-1' ) && !is_bbpress() ) : ?>

<div id="widget-area" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div><!-- .widget-area -->

<?php elseif ( is_active_sidebar( 'bbp-sidebar' ) && is_bbpress() ) : ?>

<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'bbp-sidebar' ); ?>
</div><!-- .widget-area -->

<?php endif; ?>



It does not work in the sidebar.php, left-sidebar-php and right-sidebar.php



This is all the code already existing in the sidebar-left.php





<?php
/**
* A template for calling the left sidebar on everypage
*/

global $gdlr_sidebar;
?>

<?php if( $gdlr_sidebar['type'] == 'left-sidebar' || $gdlr_sidebar['type'] == 'both-sidebar' ){ ?>
<div class="gdlr-sidebar gdlr-left-sidebar <?php echo esc_attr($gdlr_sidebar['left']); ?> columns">
<div class="gdlr-item-start-content sidebar-left-item" >
<?php dynamic_sidebar($gdlr_sidebar['left-sidebar']); ?>
</div>
</div>
<?php } ?>







Thanks!

Answers (1)

2016-05-01

Arnav Joy answers:

are you sure when you are in bbpress pages , these sidebar runs ?