try to implode $category with “,” as a glue. Mentioned code in each foreach run rewtites the cat variable of $query.
$query->set('cat', implode(',', $category));
try to implode $category with “,” as a glue. Mentioned code in each foreach run rewtites the cat variable of $query.
$query->set('cat', implode(',', $category));