ok, I just created that test scenario, and cannot replicate
Once I post a topic in one of the sub-forums the list disappears below the category on forum index.
can you post a screenshot please so that I can understand exactly what is disappearing
Here you go:
Screenshot of forum index
Screenshot of forum index after I made a topic in Sub-Forum 1
it could be a theme or plugin issue
Themes
As a test switch to a default theme such as twentytwenty, and see if this fixes.
Plugins
If that doesn’t work, also deactivate all plugins apart from bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.
If you cannot do this to your site (say because it is live) then use the ‘troubleshooting’ features of this plugin to let you test without affecting other users
Health Check & Troubleshooting
Then come back
Thanks for checking into it.
I only had bbPress installed and activated. I’ve switched to various themes including Twenty Twenty. I ran the Health and Troubleshooting, but everything seems fine. I also set up a local installation with the same result. There are no error logs either.
Not sure what could cause it if it’s only happening to me. The issue does not happen if the category and sub-forums are public.
thanks, just tested with just bbpress and agree it does disappear.
I had bbp private groups enabled, although no settings affecting, but with this it shows.
I’ll try and take a look tomorrow (10pm in UK at the moment) to see what private groups does that is fixing that !
ok, I’ve found time to take an initial look at this.
The function called looks at a database item which holds the sub forum count – but it looks like this is just count of public forums, so the count is zero, so none displayed.
so removing looking at this takes away the issue.
It would take a deal of work to see why and how to make a permanent fix to this, and I think this filter will do what you want
add_filter('bbp_forum_get_subforums', 'rew_forum_get_subforums', 10, 3);
function rew_forum_get_subforums( $sub_forums, $r, $args ) {
// Default return value
$retval = array();
// Use passed integer as post_parent
if ( is_numeric( $args ) && ! empty( $args ) ) {
$args = array( 'post_parent' => bbp_get_forum_id( $args ) );
}
// Parse arguments against default values
$r = bbp_parse_args( $args, array(
'post_parent' => 0,
'post_type' => bbp_get_forum_post_type(),
'posts_per_page' => get_option( '_bbp_forums_per_page', 50 ),
'orderby' => 'menu_order title',
'order' => 'ASC',
'ignore_sticky_posts' => true,
'no_found_rows' => true
), 'forum_get_subforums' );
// Ensure post_parent is properly set
$r['post_parent'] = bbp_get_forum_id( $r['post_parent'] );
// Query if post_parent has subforums
if ( ! empty( $r['post_parent'] ) ) {
$get_posts = new WP_Query();
$retval = $get_posts->query( $r );
}
// Filter & return
return (array) apply_filters( 'rew_forum_get_subforums', $retval, $r, $args );
}
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
Code Snippets
Thanks for taking your time to look at this! Your filter works great and fixes the issue 🙂