how to customize search results
- 
		After user searched key wards in one of the parent forums, I want to suggest topics that are a member of the parent forum. 
 For example,
 Forum Top |- Forum B |-topic A
 | |-topic F
 |
 |- Forum C |-topic A
 |-topic ZIf an user now in Forum B searches topic A, only show topic A in Forum B, not Forum C’s topic A. What I tried 
 First, I add this cord to my child theme’s function.php.
 `function my_bbp_search_form(){
 ?>
 <div class=”bbp-search-form”><?php bbp_get_template_part( ‘form’, ‘search’ ); ?> </div> 
 <?php
 }
 add_action( ‘bbp_template_before_single_forum’, ‘my_bbp_search_form’ );`Next, Add a field to the search form. I override form-search.php in my child theme’s /bbpress directory. if ( bbp_allow_search() ) : ?> <?php $forum_id = bbp_get_forum_id(); ?> <div class="bbp-search-form"> <form role="search" id="bbp-search-form" method="get" action=""> <input type="text" value="" placeholder="Search <?php the_title(); ?> Topics" name="s"/> <input type="hidden" name="forum_id" value="<?php echo $forum_id; ?>"/> <input type="submit"/> </form> </div>Finally, I filter the search query to only search a specific forum. I add this code to my functions.php. <?php function my_bbp_filter_search_results( $r ){ $s=htmlspecialchars($_GET['s'], ENT_QUOTES, 'UTF-8'); $forum_id = htmlspecialchars($_GET['forum_id'], ENT_QUOTES, 'UTF-8'); if(isset($s)){ $args=array( 's'->$s, 'post_parent'->$forum_id, ); } return $r; } ?>However, it didn’t work so I want to know how to achieve this. In addition, I challenged another way like this. if(bbp_has_topics(array('s'->$s, 'post_parent'->$forum_id))) bbp_get_template_part('bbpress/loop', 'topics');This code is that I edited above last additional functon “my_bbp_filter_search_results()” in function.php. 
 However, I can’t get search’s value(name=’s’) in the first place. I tried to use “echo $s;”, $s didn’t output the value. Where is the search results file of bbpress?Please advise me. Thanks for reading. 
- You must be logged in to reply to this topic.