I came across this code that supposedly search forum only:
/* 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');
How can I activate this for the search block on forum but not for all other search blocks on site?
Or maybe this:
function search_filter($query) {
if ($query->bbp_is_search) {
$query->set('post_type', array('post', 'forum', 'topic', 'reply'));
} else if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts', 'search_filter');
Maybe relevant. I always get lost on Github, so I can’t even conclude the status.
https://github.com/WordPress/gutenberg/pull/40585
I’m curious: why are you going out of your way to break a native WordPress feature?
Why would you not use the bbPress search shortcode… or the bbPress search block from the bbPress Style Pack plugin which you’re already using? Both can be placed anywhere just like the native search block so I’m genuinely curious to know why you seem bent on adapting the native search block instead!