Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Multisite Search › Reply To: Multisite Search
April 22, 2022 at 2:16 pm
#37624
Keymaster
Hi,
That actually might be possible via a custom code snippet. All you need to know is the blog ID and the taxonomy term ID for which you want to restrict the results to.
I have constructed a small snippet, which should do that, you only need to plug the values to the $include variable. On the left side is the blog ID, on the right side is the category to include the results for that blog.
Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
add_filter("asp_query_args", "asp_query_args_change", 10, 2);
function asp_query_args_change($args, $search_id) {
$include = array(
// Blog ID => Taxonomy term ID
1 => 11,
2 => 22,
);
if ( isset($include[get_current_blog_id()]) ) {
$args['post_tax_filter'] = array(
array(
'taxonomy' => 'category',
'include' => array($include[get_current_blog_id()]),
'exclude' => array(),
'allow_empty' => false // Don't allow results, which does not have connection with this taxonomy
)
);
}
return $args;
}