Skip to:
Content
Pages
Categories
Search
Top
Bottom

Dropdown menu with all forums – How to ?


  • blackjak231
    Participant

    @blackjak231

    Hello!

    I’m trying to display a dropdown menu with all the forums on all templates of bbPress. I was able to easily to it on the “content-archive-forum.php” template with this code :

    <?php if ( bbp_has_forums() ) : ?>
    	<?php while ( bbp_forums() ) : bbp_the_forum(); ?>
    		<li><a id="textdropdown" class="bbp-forum-title" href="<?php bbp_forum_permalink(); ?>"><?php bbp_forum_title(); ?></a></li>
    	<?php endwhile; ?>
    <?php else : ?>
    	<?php bbp_get_template_part( 'feedback', 'no-forums' ); ?>
    <?php endif; ?>

    The problem i’m having is on all other pages. I know that it’s passing the wrong forum_id to the bbp_has_forums function but i’m unable to modify the parameters or make a custom function to display a list (with links) of the MAIN forums (the one displayed on the “content-archive-forum.php”).

    Basically, it displays the message “Oh bother! No forums were found here!” on all other pages.

    Can anyone help me or tell me how to do this ?

    Thanks in advance!

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

  • selenii
    Participant

    @selenii

    Please anyone help us, I need the same function…


    Robin W
    Moderator

    @robin-w

    The problem i’m having is on all other pages

    so you altered code in “content-archive-forum.php”

    how or what are you doing for the other ‘pages’?


    Robkk
    Moderator

    @robkk

    @blackjak231 i think you should make a widget, the forum list widget does list all the forums in links all you would have to do is alter how it is displayed.

    And also since it is a widget it should work on all pages in your site.


    blackjak231
    Participant

    @blackjak231

    Thanks for the tip but i actually ended up adding the following at the top of the pages i needed it on :

    $args = array(
    	'post_parent' => 0,
    );

    Not very DRY as it is repeated (i could have done a function though…) but it does the job perfectly.
    HOWEVER, since every loop resets the $args array, i think it only works for me because my dropdown menu with the forums is before any other loop on the page.

    Here is the code i added in the pages i needed to show the dropdown (bootstrap):

    
    <?php if ( bbp_has_forums($args) ) : ?>
    	<?php while ( bbp_forums() ) : bbp_the_forum(); ?>
    		<li><a id="textdropdown" class="bbp-forum-title" href="<?php bbp_forum_permalink(); ?>"><?php bbp_forum_title(); ?></a></li>
    	<?php endwhile; ?>
    <?php else : ?>
    	<?php bbp_get_template_part( 'feedback', 'no-forums' ); ?>
    <?php endif; ?>
    

    I hope this helps you @selenii and anybody else who was trying to do this. I would however recommend Robkk’s way as it uses clean code from bbPress. Haven’t tried it though.

    Good luck and thank you!


    selenii
    Participant

    @selenii

    can you show and tell me how you make your menu, please?

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