With the existing code in the original topic and along with this snippet I had else where you should be fine to put it all together:
To get the child/sub forums from the current forum page use bbp_forum_get_subforums()
and then pass those ID’s to post_parent__in
(Note the double underscore). You can also go the other way to get ‘parents’ of the current forum with bbp_get_forum_ancestors()
.
e.g. To include forum ID’s 2
, 5
, 12
and 14
add the post_parent__in
if ( bbp_has_topics( array( 'orderby' => 'rand', 'posts_per_page' => 1, 'post_parent__in' => array( 3, 5, 12, 14 ) ) ) ) {
e.g. To exclude forum ID’s 7
, 11
, 19
and 21
add the post_parent__not_in
if ( bbp_has_topics( array( 'orderby' => 'rand', 'posts_per_page' => 1, 'post_parent__not_in' => array( 7, 9, 11, 19 ) ) ) ) {