Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbpress plugin forum specific sidebars?


  • Anointed
    Participant

    @anointed

    I need some advice on the best way to create and manage unique sidebars for each forum using the bbpress plugin.

    *having new sidebars dynamically created upon creating a new forum would be a HUGE plus! but I don’t mind having to do this manually for now if that is what it takes.

    Scenario:

    I have multiple forums and sub-forums. I want to be able to assign unique widgets to each forum and sub-forum.

    Also when I am viewing a single post, say in the forum ‘cars’, I want the sidebar assigned to ‘cars’ to show up on that single view.

    The idea is that I have posts that are directly relevant to each forum category, and I want to provide the user with direct links to the relevant posts.

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

  • John James Jacoby
    Keymaster

    @johnjamesjacoby

    There’s are a few ‘context sensitive widget’ type plugins available for WordPress that would probably be the best places to start.

    @anointed, did you ever find a good solution or plugin for this? I tried https://wordpress.org/extend/plugins/widget-context/ but putting forums/* doesn’t allow me to show/hide widgets.


    Anointed
    Participant

    @anointed

    @kai920

    I ended up going an entirely different route in order to get forum specific sidebars on the pages. JJ’s answer would have been the easiest to achieve by using widget context, but I wanted full control.

    Very long story short…

    I started by registering a custom sidebar just for the forums.

    I then took all of the bbpress templates and rewrite them from scratch to include my custom code and forum sidebar.

    *Keep in mind that bbPress templates are nothing more than WordPress templates, so all rules that you follow when building a custom theme also apply to bbPress. Trying to explain how to build custom templates is WAY outside the scope of what I can provide. There are numerous tutorials all over the internet to get you started.

    **If you are not comfortable writing template code, then widget context is definitely the way to go.

    Thanks anointed, I might follow your approach as I want to keep the forums somewhat separated from the rest of the site. Am sure I will learn many things along the way also, as an added bonus :)

    Hi!

    I have created custom sidebars.

    And I see in the .php files that there’s always the <?php get_sidebar(); ?> in the bottom. Somewhere I read that I should inside the () add the name of the forum, but where do I find this name/adress to the sidebars I have created?

    Also: I have a wordpress plug-in “user image” that lets users have profile pictures. The problem is that bbpress inserts the profil picture everywhere it inserts the username which makes the forum look really messy. Any suggestions?

    Best regards

    Aleksander


    Anointed
    Participant

    @anointed

    @eraleks

    Let’s assume that you created a new sidebar called ‘bbpress’ via your functions file. This means that when you go to the sidebar manager, that you can see one called bbpress.

    Next, take the sidebar.php file from your theme and make a copy. Name it bbpress-sidebar.php.

    Here is an example of my bbpress-sidebar.php code.

    <div id="sidebar" role="complementary">

    <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('bbpress') ) : ?>
    <?php endif; ?>

    </div>

    Finally there are a number of bbpress templates that call the sidebar. Replace those calls with:

    <?php get_sidebar( 'bbpress' ); ?>

    Wrapping up:

    1. You registered a new sidebar called ‘bbpress’

    2. You created a new template file called bbpress-sidebar.php

    3. You edited the bbpress-sidebar.php file to ask for the bbPress sidebar.

    4. You replaced all the calls to the sidebar with the new call to the bbpress sidebar.

    That’s about it. If it is still causing you problems then I suggest reading a few resources.

    https://codex.wordpress.org/Function_Reference/register_sidebar

    http://justintadlock.com/archives/2010/11/08/sidebars-in-wordpress

    *Author avatars.

    JJ already thought about this and added in a filter where you can choose to display just the username and not the avatar.

    <?php bbp_topic_author_link( array( 'type' => 'name' ) ); ?>

    You will see a lot of functions like the one above throughout the bbPress templates. Anywhere you find an avatar that you want to remove and just show the username, simply add the ‘type’ => ‘name’ and your good to go.

    **There may be a global way of doing this, but I did not look as I didn’t need it myself.

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