How to add bbpress to search results?

Hello everyone,

i was developing a bbpress based theme for a friend of mine and he wanted to display the results of the forum within wordpress native results, by default it doesn’t up till now maybe they’ll sort it along their development one day, anyways did some digging and found the following solution.

open your functions.php file in your theme folder and add the following

  • Biswadip Dasgupta

    Any idea how to add author names to the search? Best Bis

    • have you tried something like this

      function filter_search( $query ) {
      if( $query->is_search ) {
      if ( isset($_GET[‘tag’]) )
      // alter your search query here.
      return $query;
      add_filter( ‘pre_get_posts’ , ‘filter_search’ );

  • Biswadip Dasgupta

    Thanks dude this is the first page I have found on the web which helps me to add search for bbpress post_types to the wordpress search. 🙂 How do I add things like author names to the search – presumably author name is not a post type? Best Bis

  • Biswadip Dasgupta

    Hi Karim I am not sure how to “alter my search query” as you suggest. I found this on

    // Allow plugins to contextually add/remove/modify the search section of the database query
    $search = apply_filters_ref_array(‘posts_search’, array( $search, &$this ) );

    I am not sure how to modify my original query to include all users who are mentioned in posts as well as the forums you have already helped me to make searchable. Can you help?



    • what exactly do you need to do and i will help as much as i can? 🙂

      • Biswadip Dasgupta

        Thanks Karim your my_add_bbp_to_search function works brilliantly in adding the bbpress forums to my wordpress search. What I have noticed, however, is that no everything in wordpress seems to be searchable. For example, if I type in a name, all the instances when that name crops up on the site does not come up in the search results. I have tried plugins like SearchWP as well, so far without much success. Best Bis