RoboRob
RoboRob

Reputation: 195

List bbPress Forums Function

Looking for a simple bbPress function that will list all forums to iterate through with foreach(). bbp_list_forums() seems to only work for subforums.

Upvotes: 0

Views: 374

Answers (1)

RoboRob
RoboRob

Reputation: 195

My thinking was wrong about this-- you'll need to add a loop, similar to working with Wordpress itself. Here's the code that worked for me to create an array of forums keyed on their respective ID:

$forum_names = array();

if ( bbp_has_forums() ) {
    while ( bbp_forums() ) {

        bbp_the_forum();

        $forum_id = bbp_get_forum_id();

        $forum_names[$forum_id] = bbp_get_forum_title();

    } // while()
} // if()

It looks like you could work with the functions in bbpress/includes/forums/template.php to do this another way as well.

Upvotes: 1

Related Questions