public static function argCat(Query $query, $value, &$q)
{
/*
* See https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
*/
$in = [];
$notIn = [];
foreach ($value as $id) {
if ((int) $id < 0) {
$notIn[] = -$id;
} else {
$in[] = $id;
}
}
if ($in) {
$query->where('terms.category.term_id', $in);
}
if ($notIn) {
$query->whereNot('terms.category.term_id', $notIn);
}
}