filter search results affects buddyboss discussions

Hi there!

I hoop that anyone can help me with this! I build a page for an online course/community and now I want to integrate a video dictionary. I used the post function of wp for the entries of my dictionary and the themebuilder of elementor for the search page. I wanted to limit the search results to only one post category (“gebaren”). Because I don’t know anything about coding I tried it with chat gpt and to my surprise it worked as a charme with this php code in the code snippet plugin:

add_action(‘pre_get_posts’, ‘filter_search_results_by_category’);
function filter_search_results_by_category($query) {
if (!is_admin() && $query->is_search()) {
$query->set(‘category_name’, ‘gebaren’);
}
return $query;

Unfortunately the code also affects the reply’s on the forum of the buddyboss theme. Has anyone an idea how to correct this?

​

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer