Display bbPress Recent 5 or more Topics on WordPress Frontpage or any other WordPress template. In this site I put it right before the recent Posts list on the Main Index of my Theme Template.
Add this code to your Template:
<?php if ( bbp_has_topics( array( 'author' => 0, 'show_stickies' => false, 'order' => 'DESC', 'post_parent' => 'any', 'posts_per_page' => 5 ) ) ) bbp_get_template_part( 'bbpress/loop', 'topics' ); ?>
In the code you can choose how many Topics to display, just change where it says posts_per_page
Additional tips:
When you inset the code the topic lists will not look like the forums, but you can style it to look like the forums by putting the code in between a div tag and giving the div tag id=”bbpress-forums”
<div id="bbpress-forums"> <?php if ( bbp_has_topics( array( 'author' => 0, 'show_stickies' => false, 'order' => 'DESC', 'post_parent' => 'any', 'posts_per_page' => 5 ) ) ) bbp_get_template_part( 'bbpress/loop', 'topics' ); ?> </div>
And the Final code to display it just in the Frontpage in case thats what you want is this:
<?php if( is_front_page() && ( $paged < 2 ) ) : ?> <div class="toBeReplaced" id="bbpress-forums"> <?php if ( bbp_has_topics( array( 'author' => 0, 'show_stickies' => false, 'order' => 'DESC', 'post_parent' => 'any', 'posts_per_page' => 5 ) ) ) bbp_get_template_part( 'bbpress/loop', 'topics' ); ?> </div> <?php endif;?>
Additionally as you can see I added a class I did that to change the word Topic to Recent Topics
using this CSS Trick:
.toBeReplaced .forum-titles .bbp-topic-title{ visibility: hidden; position: relative; } .toBeReplaced .forum-titles .bbp-topic-title:after { visibility: visible; position: absolute; top: 0; left: 0; content: "Recent Topics"; }