Skip to:

Display only 5 recent topics and show certain forums?

  • strangelife


    Hi Everyone!

    For my main forum homepage or the archive i want to display different forums into sections rather than having a list of forums that is the bbpress default.

    So this is the code used to display all the forums,

    <?php while ( bbp_forums() ) : bbp_the_forum(); ?>
    	<?php bbp_get_template_part( 'loop', 'single-forum' ); ?>
    <?php endwhile; ?>

    So how would i add some arguments to this to display certain forums from there ID’s?

    Also on the main page i want to show 5 recent topics, i believe the loop code is this,

    <?php while ( bbp_topics() ) : bbp_the_topic(); ?>
    	<?php bbp_get_template_part( 'loop', 'single-topic' ); ?>
    <?php endwhile; ?>

    If anyone has managed to use a custom loop using the above code to display 5 recent topics or a custom WP_Query, i’ll be very grateful if you could show some example code.

    Kind Regards
    ~ Matt

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

  • inspirationally


    Did you find out already? I wanted to do the same.



    I too am looking for examples for displaying the latest replies, topics etc. from specific forums.

    I am resorting to trying to get the information from the database with mysql queries but because a reply has a parent of topic which has a parent of forum_id I am not sure how to get the forum_id of a reply.



    Found out –
    you can simply use Widgets inside your template.

    I also installed the tehnik-bbpress-permissions plugin to not show the hidden forums topics and put this into my template:

    <?php the_widget( 'Tehnik_BBP_Replies_Widget', $instance, $args ); ?> 

    This should work with the default BBP Replies Widget, too (just need to find out the name of it)

    Will try a bit more customization today with an eye on

    Another possibility is manually:

    	<?php do_action( 'bbp_template_before_topics_index' ); ?>
            <?php if ( bbp_has_topics( array( 'author' => 0, 'show_stickies' => false, 'order' => 'DESC', 'post_parent' => 'any', 'posts_per_page' => 5 ) ) ) : ?>
                    <?php bbp_get_template_part( 'bbpress/loop', 'recent-topics' ); ?>
            <?php else : ?>
                    <?php bbp_get_template_part( 'bbpress/feedback', 'no-topics' ); ?>
            <?php endif; ?>
    	<?php do_action( 'bbp_template_after_topics_index' ); ?>
Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.