Skip to:
Content
Pages
Categories
Search
Top
Bottom

Different sidebars for groups


  • hlubi
    Participant

    @hlubi

    Hi

    I want to create a platform where users can post on separate content on different pages. I have thus used Groups to facilitate this, but how do I create different sidebars for each group?

    I have effectively replaced “pages” with “groups”

Viewing 2 replies - 1 through 2 (of 2 total)

  • Boone Gorges
    Keymaster

    @boonebgorges

    Hi @hlubi – Generally, the sidebar is controlled by the WP theme you’re using. See sidebar.php. You’ll likely need to make your modifications in that file (probably in a child theme, if you’re not already using one).

    Exactly what modifications you make depends heavily on how you want the sidebars to differ. If you have a small number of groups, and you want the sidebar to be totally customized for each one, sidebar.php might look something like this:

    
    if ( bp_is_group() ) {
        $group_id = bp_get_current_group_id();
    
        switch ( $group_id ) {
            case 1 :
                 // group 1 sidebar
            break;
    
            case 2 :
                 // group 2 sidebar
            break;
        }
    } else {
        // existing sidebar code
    }
    

    You could even register separate sidebars for each group, so that they can be managed separately in wp-admin. (This solution obviously won’t work well if you have lots and lots of groups.)

    If you just want to have some group-specific content in the sidebar, you can use BP’s “current group” functions in sidebar.php. For example:

    
    if ( bp_is_group() ) {
        $current_group = groups_get_current_group();
        printf( 'This is the sidebar for group %s', esc_html( $current_group->name ) );
    }
    

    This way, you’d have the same *type* of data on each group’s sidebar, but the specific data would be pulled dynamically based on which group is being shown.


    hlubi
    Participant

    @hlubi

    Thank you.
    The most groups I would have is 50.

    Each sidebar should be administered via direct posts individually.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar