I’m creating a customised forums front page for bbPress, by listing forums in a different way to the bbPress default.
Essentially what I’m trying to do is replace the use of bbp_list_forums() with a second, nested bbPress loop so that I have greater control over how the sub-forums are displayed.
I know I can use the ‘before’ and ‘after’ parameters of bbp_list_forums() but that doesn’t give me as much control as I need.
The only question I found that came close was this one which doesn’t actually provide a definitive answer.
My code so far is like so;
<?php while ( bbp_forums() ) : bbp_the_forum(); ?>
<li class="bbp-header">
<ul class="forum-titles">
<li class="bbp-forum-info"><?php bbp_forum_title(); ?></li>
<li class="bbp-forum-freshness"><?php _e( 'Latest post', 'youngsibs' ); ?></li>
<li class="bbp-forum-topic-count"><?php _e( 'Threads', 'youngsibs' ); ?></li>
<li class="bbp-forum-reply-count"><?php bbp_show_lead_topic() ? _e( 'Replies', 'bbpress' ) : _e( 'Posts', 'bbpress' ); ?></li>
</ul>
</li><!-- .bbp-header -->
<li class="bbp-body">
<?php
bbp_list_forums(array(
'before' => '<ul id="bbp-forum-'.bbp_get_forum_id().'" '.bbp_get_forum_class().'>',
'after' => '</ul>',
'link_before' => '<li class="bbp-forum-info">',
'link_after' => '</li>',
'count_before' => '<li class="bbp-forum-topic-count">',
'count_after' => '</li>',
'count_sep' => '</li><li class="bbp-forum-reply-count">',
'separator' => '</ul><ul id="bbp-forum-'.bbp_get_forum_id().'" '.bbp_get_forum_class().'>',
'forum_id' => '',
'show_topic_count' => true,
'show_reply_count' => true
));
?>
</li><!-- .bbp-body -->
<li class="bbp-footer">
<div class="tr">
<p class="td colspan4"> </p>
</div><!-- .tr -->
</li><!-- .bbp-footer -->
<?php endwhile; ?>
See the bbp_list_forums() reference – in place of that I want another “while (bbp_forums())…” loop but how do I do that without interfering with the main loop?
Had exactly the same problem. Found that great article by Scott Taylor and managed to mimic his functions to work for forums.