from a very quick look, that code looks like it should work, and not seen anything else that does this, so try it, and if it doesn’t work, come back
Hey Robin, Thanks for the reply, really appreciate it. I added this to my themes functions.php (from the article above), but hardcoded in a forum_id, just to test it out, and it doesn’t seem to work.
function my_bbp_filter_search_results( $r ){
$forum_id = 1715;
if( $forum_id && is_numeric( $forum_id ) ){
$r['meta_query'] = array(
array(
'key' => '_bbp_forum_id',
'value' => $forum_id, // 1715 x , 11 , 1717 ,
'compare' => '=',
)
);
}
error_log('Dedicated forum = ' . $forum_id);
return $r;
}
add_filter( 'bbp_after_has_search_results_parse_args' , 'my_bbp_filter_search_results' );
the error log is coming through when the page is loaded, but i’m still getting discussions from other forums in the search results.
ok, try this
add_filter( 'bbp_before_has_search_results_parse_args' , 'my_bbp_filter_search_results' );
function my_bbp_filter_search_results( $args ){
$forum_id = 1715;
if( $forum_id && is_numeric( $forum_id ) ){
$args['post_parent'] = $forum_id ;
}
error_log('Dedicated forum = ' . $forum_id);
return $args;
}
Hey Robin, thanks for the feedback, this doesn’t seem to be working either though 🙁
just tried that code on my test site and it works fine.
where are you putting it ?