bbpress 2.4.1 comes with it’s own search function, which only searches forums.
this post also describes forum only search boxes which might help
http://vfbpro.com/2012/10/25/how-to-add-a-search-box-to-bbpress/
and also a widget
https://wordpress.org/plugins/bbpress-search-widget/
that you could crack the code of
You are right. There’s a problem because WordPress filters all searches, including the bbPress. Now I don’t know how to recognize if the search is coming from WordPress’s search box or bbPress’s searchbox.
I don’t need search box for forum on first/home page, but I need to filter results when searching with WordPress’s search box. I must not show pages in it, so that’s why I’m searching solution.
Thank you!
I found out that I misunderstood your post. I downloaded plugin that you suggested and checked the code. I remembered that I used is_bbpress() somewhere and that was the solution for my problem. There’s the snippet of code that I used in my theme in file functions.php:
/* Do not search pages, only posts and if there's a request from bbPress or Admin panel than ignore setting of post type */
function search_filter($query) {
if ($query->is_search && !is_admin() && !is_bbpress()) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts', 'search_filter');
Thank you very much again! 🙂 🙂
Great, glad you’re fixed !