The Wayback Machine - https://web.archive.org/web/20201126230615/https://bbpress.org/forums/topic/bbp-search-on-a-single-forum/
Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbp-search on a single forum

Viewing 5 replies - 1 through 5 (of 5 total)
  • Image
    Robin W
    Moderator

    @robin-w

    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

    Image
    talbotp
    Participant

    @talbotp

    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.

    Image
    Robin W
    Moderator

    @robin-w

    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;
    }
    
    Image
    talbotp
    Participant

    @talbotp

    Hey Robin, thanks for the feedback, this doesn’t seem to be working either though 🙁

    Image
    Robin W
    Moderator

    @robin-w

    just tried that code on my test site and it works fine.

    where are you putting it ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar